MCPcopy
hub / github.com/genuinetools/img / testBuildOutputArchive

Function testBuildOutputArchive

build_test.go:207–234  ·  view source on GitHub ↗
(otype string, t *testing.T)

Source from the content-addressed store, hash-verified

205}
206
207func testBuildOutputArchive(otype string, t *testing.T) {
208
209 tmpd, err := ioutil.TempDir("", "img-buildoutput"+otype)
210 if err != nil {
211 t.Fatalf("creating temporary directory for build output failed: %v", err)
212 }
213 defer os.RemoveAll(tmpd)
214 archive := filepath.Join(tmpd, "output.tar")
215
216 args := []string{"build", "-", "-o", fmt.Sprintf("type=%s,dest=%s", otype, archive)}
217 _, err = doRun(args, withDockerfile(`
218 FROM busybox
219 `))
220 if err != nil {
221 t.Fatalf("img %v failed unexpectedly: %v", args, err)
222 }
223
224 // Make sure the output is a valid tar archive.
225 f, err := os.Open(archive)
226 if err != nil {
227 t.Fatalf("could not open output archive at %q: %s", archive, err)
228 }
229 defer f.Close()
230 tr := tar.NewReader(f)
231 if _, err = tr.Next(); err != nil {
232 t.Fatalf("could not read first item in %s archive: %s", otype, err)
233 }
234}
235
236func TestBuildOutputTar(t *testing.T) {
237 testBuildOutputArchive("tar", t)

Callers 3

TestBuildOutputTarFunction · 0.85
TestBuildOutputDockerFunction · 0.85
TestBuildOutputOCIFunction · 0.85

Calls 3

doRunFunction · 0.85
withDockerfileFunction · 0.85
CloseMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…