(ctx context.Context, root string)
| 30 | ) |
| 31 | |
| 32 | func newContentStore(ctx context.Context, root string) (context.Context, content.Store, func() error, error) { |
| 33 | client, err := New(address) |
| 34 | if err != nil { |
| 35 | return nil, nil, nil, err |
| 36 | } |
| 37 | |
| 38 | var ( |
| 39 | count atomic.Uint64 |
| 40 | cs = client.ContentStore() |
| 41 | name = testsuite.Name(ctx) |
| 42 | ) |
| 43 | |
| 44 | wrap := func(ctx context.Context, sharedNS bool) (context.Context, func(context.Context) error, error) { |
| 45 | n := count.Add(1) |
| 46 | ctx = namespaces.WithNamespace(ctx, fmt.Sprintf("%s-n%d", name, n)) |
| 47 | return client.WithLease(ctx) |
| 48 | } |
| 49 | |
| 50 | ctx = testsuite.SetContextWrapper(ctx, wrap) |
| 51 | |
| 52 | return ctx, cs, func() error { |
| 53 | for i := uint64(1); i <= count.Load(); i++ { |
| 54 | ctx = namespaces.WithNamespace(ctx, fmt.Sprintf("%s-n%d", name, i)) |
| 55 | statuses, err := cs.ListStatuses(ctx) |
| 56 | if err != nil { |
| 57 | return err |
| 58 | } |
| 59 | for _, st := range statuses { |
| 60 | if err := cs.Abort(ctx, st.Ref); err != nil && !errdefs.IsNotFound(err) { |
| 61 | return fmt.Errorf("failed to abort %s: %w", st.Ref, err) |
| 62 | } |
| 63 | } |
| 64 | err = cs.Walk(ctx, func(info content.Info) error { |
| 65 | if err := cs.Delete(ctx, info.Digest); err != nil { |
| 66 | if errdefs.IsNotFound(err) { |
| 67 | return nil |
| 68 | } |
| 69 | |
| 70 | return err |
| 71 | } |
| 72 | return nil |
| 73 | }) |
| 74 | if err != nil { |
| 75 | return err |
| 76 | } |
| 77 | } |
| 78 | return nil |
| 79 | |
| 80 | }, nil |
| 81 | } |
| 82 | |
| 83 | func TestContentClient(t *testing.T) { |
| 84 | if testing.Short() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…