(ctx context.Context, root string, opts ...DBOpt)
| 38 | ) |
| 39 | |
| 40 | func createContentStore(ctx context.Context, root string, opts ...DBOpt) (context.Context, content.Store, func() error, error) { |
| 41 | // TODO: Use mocked or in-memory store |
| 42 | cs, err := local.NewStore(root) |
| 43 | if err != nil { |
| 44 | return nil, nil, nil, err |
| 45 | } |
| 46 | |
| 47 | db, err := bolt.Open(filepath.Join(root, "metadata.db"), 0660, nil) |
| 48 | if err != nil { |
| 49 | return nil, nil, nil, err |
| 50 | } |
| 51 | |
| 52 | var ( |
| 53 | count atomic.Uint64 |
| 54 | name = testsuite.Name(ctx) |
| 55 | ) |
| 56 | wrap := func(ctx context.Context, sharedNS bool) (context.Context, func(context.Context) error, error) { |
| 57 | n := count.Add(1) |
| 58 | ctx2 := namespaces.WithNamespace(ctx, fmt.Sprintf("%s-n%d", name, n)) |
| 59 | if sharedNS { |
| 60 | db.Update(func(tx *bolt.Tx) error { |
| 61 | if ns, err := namespaces.NamespaceRequired(ctx2); err == nil { |
| 62 | return NewNamespaceStore(tx).SetLabel(ctx2, ns, labels.LabelSharedNamespace, "true") |
| 63 | } |
| 64 | return err |
| 65 | }) |
| 66 | } |
| 67 | return ctx2, func(context.Context) error { |
| 68 | return nil |
| 69 | }, nil |
| 70 | } |
| 71 | ctx = testsuite.SetContextWrapper(ctx, wrap) |
| 72 | |
| 73 | return ctx, NewDB(db, cs, nil, opts...).ContentStore(), func() error { |
| 74 | return db.Close() |
| 75 | }, nil |
| 76 | } |
| 77 | |
| 78 | func createContentStoreWithPolicy(opts ...DBOpt) testsuite.StoreInitFn { |
| 79 | return func(ctx context.Context, root string) (context.Context, content.Store, func() error, error) { |
no test coverage detected
searching dependent graphs…