Add content test suite
Add content test suite with test for writer. Update fs and metadata implementations to use test suite. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
@@ -385,13 +385,14 @@ func (nw *namespacedWriter) commit(tx *bolt.Tx, size int64, expected digest.Dige
|
||||
return err
|
||||
}
|
||||
|
||||
timeEncoded, err := status.UpdatedAt.MarshalBinary()
|
||||
timeEncoded, err := time.Now().UTC().MarshalBinary()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, v := range [][2][]byte{
|
||||
{bucketKeyCreatedAt, timeEncoded},
|
||||
{bucketKeyUpdatedAt, timeEncoded},
|
||||
{bucketKeySize, sizeEncoded},
|
||||
} {
|
||||
if err := bkt.Put(v[0], v[1]); err != nil {
|
||||
|
||||
30
metadata/content_test.go
Normal file
30
metadata/content_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package metadata
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
"github.com/containerd/containerd/content"
|
||||
"github.com/containerd/containerd/content/fs"
|
||||
"github.com/containerd/containerd/content/testsuite"
|
||||
)
|
||||
|
||||
func TestContent(t *testing.T) {
|
||||
testsuite.ContentSuite(t, "metadata", func(ctx context.Context, root string) (content.Store, func(), error) {
|
||||
// TODO: Use mocked or in-memory store
|
||||
cs, err := fs.NewStore(root)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
db, err := bolt.Open(filepath.Join(root, "metadata.db"), 0660, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
cs = NewContentStore(db, cs)
|
||||
|
||||
return cs, func() {}, nil
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user