(otype string, t *testing.T)
| 205 | } |
| 206 | |
| 207 | func 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 | |
| 236 | func TestBuildOutputTar(t *testing.T) { |
| 237 | testBuildOutputArchive("tar", t) |
no test coverage detected
searching dependent graphs…