(t *testing.T, snapshotters map[string]snapshots.Snapshotter, candidates []*plugin.Registration)
| 128 | } |
| 129 | |
| 130 | func newTestInitContext(t *testing.T, snapshotters map[string]snapshots.Snapshotter, candidates []*plugin.Registration) (*metadata.DB, *plugin.InitContext) { |
| 131 | t.Helper() |
| 132 | |
| 133 | cs, err := contentlocal.NewStore(t.TempDir()) |
| 134 | if err != nil { |
| 135 | t.Fatal(err) |
| 136 | } |
| 137 | |
| 138 | bdb, err := bolt.Open(filepath.Join(t.TempDir(), "metadata.db"), 0o644, nil) |
| 139 | if err != nil { |
| 140 | t.Fatal(err) |
| 141 | } |
| 142 | t.Cleanup(func() { |
| 143 | if err := bdb.Close(); err != nil { |
| 144 | t.Fatal(err) |
| 145 | } |
| 146 | }) |
| 147 | |
| 148 | db := metadata.NewDB(bdb, cs, snapshotters) |
| 149 | ps := plugin.NewPluginSet() |
| 150 | for name, sn := range snapshotters { |
| 151 | ic := plugin.NewContext(t.Context(), ps, nil) |
| 152 | p := (&plugin.Registration{ |
| 153 | Type: plugins.SnapshotPlugin, |
| 154 | ID: name, |
| 155 | InitFn: func(*plugin.InitContext) (any, error) { |
| 156 | return sn, nil |
| 157 | }, |
| 158 | }).Init(ic) |
| 159 | if err := ps.Add(p); err != nil { |
| 160 | t.Fatal(err) |
| 161 | } |
| 162 | } |
| 163 | for _, candidate := range candidates { |
| 164 | ic := plugin.NewContext(t.Context(), ps, nil) |
| 165 | if err := ps.Add(candidate.Init(ic)); err != nil { |
| 166 | t.Fatal(err) |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | return db, plugin.NewContext(t.Context(), ps, nil) |
| 171 | } |
| 172 | |
| 173 | func newTestDiffPlugin(id string, applier diff.Applier, err error, supported ...ocispec.Platform) *plugin.Registration { |
| 174 | return &plugin.Registration{ |
no test coverage detected
searching dependent graphs…