MCPcopy Create free account
hub / github.com/docker/cli / TestImportZipInvalid

Function TestImportZipInvalid

cli/context/store/store_test.go:214–237  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

212}
213
214func TestImportZipInvalid(t *testing.T) {
215 testDir := t.TempDir()
216 zf := path.Join(testDir, "test.zip")
217
218 f, err := os.Create(zf)
219 assert.NilError(t, err)
220 defer f.Close()
221 w := zip.NewWriter(f)
222
223 df, err := w.Create("dummy-file")
224 assert.NilError(t, err)
225 _, err = df.Write([]byte("hello world"))
226 assert.NilError(t, err)
227 err = w.Close()
228 assert.NilError(t, err)
229
230 source, err := os.Open(zf)
231 assert.NilError(t, err)
232 defer source.Close()
233 var r io.Reader = source
234 s := New(testDir, testCfg)
235 err = Import("zipInvalid", s, r)
236 assert.ErrorContains(t, err, "unexpected context file")
237}
238
239func TestCorruptMetadata(t *testing.T) {
240 tempDir := t.TempDir()

Callers

nothing calls this directly

Calls 4

ImportFunction · 0.85
NewFunction · 0.70
CloseMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…