1package deb 2 3import ( 4 "github.com/aptly-dev/aptly/database" 5 "github.com/aptly-dev/aptly/utils" 6 7 . "gopkg.in/check.v1" 8) 9 10type ChecksumCollectionSuite struct { 11 collection *ChecksumCollection 12 c utils.ChecksumInfo 13 db database.Storage 14} 15 16var _ = Suite(&ChecksumCollectionSuite{}) 17 18func (s *ChecksumCollectionSuite) SetUpTest(c *C) { 19 s.c = utils.ChecksumInfo{ 20 Size: 124, 21 MD5: "da39a3ee5e6b4b0d3255bfef95601890afd80709", 22 SHA1: "da39a3ee5e6b4b0d3255bfef95601890afd80709", 23 SHA256: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 24 } 25 s.db, _ = database.NewOpenDB(c.MkDir()) 26 s.collection = NewChecksumCollection(s.db) 27} 28 29func (s *ChecksumCollectionSuite) TearDownTest(c *C) { 30 s.db.Close() 31} 32 33func (s *ChecksumCollectionSuite) TestFlow(c *C) { 34 // checksum not stored 35 checksum, err := s.collection.Get("some/path") 36 c.Assert(err, IsNil) 37 c.Check(checksum, IsNil) 38 39 // store checksum 40 err = s.collection.Update("some/path", &s.c) 41 c.Assert(err, IsNil) 42 43 // load it back 44 checksum, err = s.collection.Get("some/path") 45 c.Assert(err, IsNil) 46 c.Check(*checksum, DeepEquals, s.c) 47} 48