func (s *MetadataSuite) TestFileMetadataSetStoredDefault(c *gc.C) { meta := filestorage.NewMetadata() c.Assert(meta.Stored(), gc.IsNil) meta.SetStored(nil) c.Check(meta.Stored(), gc.NotNil) }
func (s *MetadataSuite) TestFileMetadataDoc(c *gc.C) { meta := filestorage.NewMetadata(nil) meta.SetFile(10, "some sum", "SHA-1") doc := meta.Doc() c.Check(doc, gc.Equals, meta) }
func (s *MetadataSuite) TestFileMetadataSetStored(c *gc.C) { meta := filestorage.NewMetadata() timestamp := time.Now().UTC() meta.SetStored(×tamp) c.Check(meta.Stored(), gc.Equals, ×tamp) }
func (s *MetadataSuite) TestFileMetadataSetStored(c *gc.C) { meta := filestorage.NewMetadata(nil) meta.SetFile(10, "some sum", "SHA-1") c.Assert(meta.Stored(), gc.Equals, false) meta.SetStored() c.Check(meta.Stored(), gc.Equals, true) }
func (s *MetadataSuite) TestFileMetadataNewMetadata(c *gc.C) { meta := filestorage.NewMetadata() c.Check(meta.ID(), gc.Equals, "") c.Check(meta.Size(), gc.Equals, int64(0)) c.Check(meta.Checksum(), gc.Equals, "") c.Check(meta.ChecksumFormat(), gc.Equals, "") c.Check(meta.Stored(), gc.IsNil) }
// NewMetadata returns a new Metadata for a state backup archive. Only // the start time and the version are set. func NewMetadata() *Metadata { return &Metadata{ FileMetadata: filestorage.NewMetadata(), Started: time.Now().UTC(), Origin: Origin{ Version: version.Current, }, } }
func (s *MetadataSuite) TestFileMetadataSetIDInitial(c *gc.C) { meta := filestorage.NewMetadata() meta.SetFileInfo(10, "some sum", "SHA-1") c.Assert(meta.ID(), gc.Equals, "") success := meta.SetID("some id") c.Check(success, gc.Equals, false) c.Check(meta.ID(), gc.Equals, "some id") }
func (s *WrapperSuite) SetUpTest(c *gc.C) { s.IsolationSuite.SetUpTest(c) var err error s.rawstor, err = filestorage.NewRawFileStorage(c.MkDir()) c.Assert(err, gc.IsNil) s.metastor = filestorage.NewMetadataStorage() s.original = filestorage.NewMetadata(nil) s.original.SetFile(10, "", "") }
func (s *MetadataSuite) TestFileMetadataSetIDAlreadySetDifferent(c *gc.C) { meta := filestorage.NewMetadata() meta.SetFileInfo(10, "some sum", "SHA-1") success := meta.SetID("some id") c.Assert(success, gc.Equals, false) success = meta.SetID("another id") c.Check(success, gc.Equals, true) c.Check(meta.ID(), gc.Equals, "some id") }
// NewMetadata returns a new Metadata for a state backup archive. Only // the start time and the version are set. func NewMetadata() *Metadata { return &Metadata{ FileMetadata: filestorage.NewMetadata(), // TODO(fwereade): 2016-03-17 lp:1558657 Started: time.Now().UTC(), Origin: Origin{ Version: jujuversion.Current, }, } }
func (s *MetadataSuite) TestFileMetadataSetIDAlreadySetSame(c *gc.C) { meta := filestorage.NewMetadata(nil) meta.SetFile(10, "some sum", "SHA-1") success := meta.SetID("some id") c.Assert(success, gc.Equals, false) success = meta.SetID("some id") c.Check(success, gc.Equals, true) c.Check(meta.ID(), gc.Equals, "some id") }
func (s *WrapperSuite) TestFileStorageListTwo(c *gc.C) { stor := filestorage.NewFileStorage(s.metastor, s.rawstor) original1 := filestorage.NewMetadata(nil) id1, err := stor.Add(original1, nil) c.Assert(err, gc.IsNil) original2 := filestorage.NewMetadata(nil) id2, err := stor.Add(original2, nil) c.Assert(err, gc.IsNil) list, err := stor.List() c.Check(err, gc.IsNil) c.Assert(list, gc.HasLen, 2) c.Assert(list[0], gc.NotNil) c.Assert(list[1], gc.NotNil) if list[0].ID() == id1 { c.Check(list[1].ID(), gc.Equals, id2) } else { c.Check(list[1].ID(), gc.Equals, id1) } }
func (s *MetadataSuite) TestFileMetadataNewMetadata(c *gc.C) { timestamp := time.Now().UTC() meta := filestorage.NewMetadata(×tamp) c.Check(meta.ID(), gc.Equals, "") c.Check(meta.Size(), gc.Equals, int64(0)) c.Check(meta.Checksum(), gc.Equals, "") c.Check(meta.ChecksumFormat(), gc.Equals, "") c.Check(meta.Timestamp(), gc.Equals, timestamp) c.Check(meta.Stored(), gc.Equals, false) }
func (s *MetadataSuite) TestFileMetadataSetFileInfo(c *gc.C) { meta := filestorage.NewMetadata() c.Assert(meta.Size(), gc.Equals, int64(0)) c.Assert(meta.Checksum(), gc.Equals, "") c.Assert(meta.ChecksumFormat(), gc.Equals, "") c.Assert(meta.Stored(), gc.IsNil) meta.SetFileInfo(10, "some sum", "SHA-1") c.Check(meta.Size(), gc.Equals, int64(10)) c.Check(meta.Checksum(), gc.Equals, "some sum") c.Check(meta.ChecksumFormat(), gc.Equals, "SHA-1") c.Check(meta.Stored(), gc.IsNil) }
func (s *MetadataStorageSuite) SetUpTest(c *gc.C) { s.IsolationSuite.SetUpTest(c) s.original = filestorage.NewMetadata(nil) s.original.SetFile(0, "", "") }
func (s *MetadataSuite) TestFileMetadataNewMetadataDefaultTimestamp(c *gc.C) { meta := filestorage.NewMetadata(nil) c.Check(meta.ID(), gc.Equals, "") c.Check(meta.Timestamp(), gc.NotNil) }
// NewMetadata returns a new Metadata for a state backup archive. The // current date/time is used for the timestamp and the default checksum // format is used. ID is not set. That is left up to the persistence // layer. Stored is set as false. "notes" may be empty, but // everything else should be provided. func NewMetadata(origin Origin, notes string, started *time.Time) *Metadata { raw := filestorage.NewMetadata(started) metadata := Metadata{*raw, nil, origin, notes} return &metadata }
func (s *WrapperSuite) metadata() filestorage.Metadata { meta := filestorage.NewMetadata() meta.SetFileInfo(10, "", "") return meta }