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

Function TestImportTarInvalid

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

Source from the content-addressed store, hash-verified

134}
135
136func TestImportTarInvalid(t *testing.T) {
137 testDir := t.TempDir()
138 tf := path.Join(testDir, "test.context")
139
140 f, err := os.Create(tf)
141 assert.NilError(t, err)
142 defer f.Close()
143
144 tw := tar.NewWriter(f)
145 hdr := &tar.Header{
146 Name: "dummy-file",
147 Mode: 0o600,
148 Size: int64(len("hello world")),
149 }
150 err = tw.WriteHeader(hdr)
151 assert.NilError(t, err)
152 _, err = tw.Write([]byte("hello world"))
153 assert.NilError(t, err)
154 err = tw.Close()
155 assert.NilError(t, err)
156
157 source, err := os.Open(tf)
158 assert.NilError(t, err)
159 defer source.Close()
160 var r io.Reader = source
161 s := New(testDir, testCfg)
162 err = Import("tarInvalid", s, r)
163 assert.ErrorContains(t, err, "unexpected context file")
164}
165
166func TestImportZip(t *testing.T) {
167 testDir := t.TempDir()

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…