mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-12 03:21:33 +00:00
This is spin-off of changes from #459. Transactions are not being used yet, but batches are updated to work with the new API. `database/` package was refactored to split abstract interfaces and implementation via goleveldb. This should make it easier to implement new database types.
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package deb
|
|
|
|
import (
|
|
"github.com/aptly-dev/aptly/database"
|
|
"github.com/aptly-dev/aptly/database/goleveldb"
|
|
"github.com/aptly-dev/aptly/utils"
|
|
|
|
. "gopkg.in/check.v1"
|
|
)
|
|
|
|
type ChecksumCollectionSuite struct {
|
|
collection *ChecksumCollection
|
|
c utils.ChecksumInfo
|
|
db database.Storage
|
|
}
|
|
|
|
var _ = Suite(&ChecksumCollectionSuite{})
|
|
|
|
func (s *ChecksumCollectionSuite) SetUpTest(c *C) {
|
|
s.c = utils.ChecksumInfo{
|
|
Size: 124,
|
|
MD5: "da39a3ee5e6b4b0d3255bfef95601890afd80709",
|
|
SHA1: "da39a3ee5e6b4b0d3255bfef95601890afd80709",
|
|
SHA256: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
}
|
|
s.db, _ = goleveldb.NewOpenDB(c.MkDir())
|
|
s.collection = NewChecksumCollection(s.db)
|
|
}
|
|
|
|
func (s *ChecksumCollectionSuite) TearDownTest(c *C) {
|
|
s.db.Close()
|
|
}
|
|
|
|
func (s *ChecksumCollectionSuite) TestFlow(c *C) {
|
|
// checksum not stored
|
|
checksum, err := s.collection.Get("some/path")
|
|
c.Assert(err, IsNil)
|
|
c.Check(checksum, IsNil)
|
|
|
|
// store checksum
|
|
err = s.collection.Update("some/path", &s.c)
|
|
c.Assert(err, IsNil)
|
|
|
|
// load it back
|
|
checksum, err = s.collection.Get("some/path")
|
|
c.Assert(err, IsNil)
|
|
c.Check(*checksum, DeepEquals, s.c)
|
|
}
|