(t *testing.T)
| 266 | } |
| 267 | |
| 268 | func TestBuildWithDockerfile(t *testing.T) { |
| 269 | nerdtest.Setup() |
| 270 | |
| 271 | dockerfile := fmt.Sprintf(`FROM %s |
| 272 | CMD ["echo", "nerdctl-build-test-dockerfile"] |
| 273 | `, testutil.CommonImage) |
| 274 | |
| 275 | testCase := &test.Case{ |
| 276 | Require: nerdtest.Build, |
| 277 | Setup: func(data test.Data, helpers test.Helpers) { |
| 278 | data.Temp().Save(dockerfile, "test", "Dockerfile") |
| 279 | data.Labels().Set("buildCtx", data.Temp().Path("test")) |
| 280 | }, |
| 281 | SubTests: []*test.Case{ |
| 282 | { |
| 283 | Description: "Dockerfile ..", |
| 284 | Cleanup: func(data test.Data, helpers test.Helpers) { |
| 285 | helpers.Anyhow("rmi", "-f", data.Identifier()) |
| 286 | }, |
| 287 | Command: func(data test.Data, helpers test.Helpers) test.TestableCommand { |
| 288 | cmd := helpers.Command("build", "-t", data.Identifier(), "-f", "Dockerfile", "..") |
| 289 | cmd.WithCwd(data.Labels().Get("buildCtx")) |
| 290 | return cmd |
| 291 | }, |
| 292 | Expected: test.Expects(expect.ExitCodeSuccess, nil, nil), |
| 293 | }, |
| 294 | { |
| 295 | Description: "Dockerfile .", |
| 296 | Cleanup: func(data test.Data, helpers test.Helpers) { |
| 297 | helpers.Anyhow("rmi", "-f", data.Identifier()) |
| 298 | }, |
| 299 | Command: func(data test.Data, helpers test.Helpers) test.TestableCommand { |
| 300 | cmd := helpers.Command("build", "-t", data.Identifier(), "-f", "Dockerfile", ".") |
| 301 | cmd.WithCwd(data.Labels().Get("buildCtx")) |
| 302 | return cmd |
| 303 | }, |
| 304 | Expected: test.Expects(expect.ExitCodeSuccess, nil, nil), |
| 305 | }, |
| 306 | { |
| 307 | Description: "../Dockerfile .", |
| 308 | Command: func(data test.Data, helpers test.Helpers) test.TestableCommand { |
| 309 | cmd := helpers.Command("build", "-t", data.Identifier(), "-f", "../Dockerfile", ".") |
| 310 | cmd.WithCwd(data.Labels().Get("buildCtx")) |
| 311 | return cmd |
| 312 | }, |
| 313 | Expected: test.Expects(1, nil, nil), |
| 314 | }, |
| 315 | }, |
| 316 | } |
| 317 | |
| 318 | testCase.Run(t) |
| 319 | } |
| 320 | |
| 321 | func TestBuildLocal(t *testing.T) { |
| 322 | nerdtest.Setup() |
nothing calls this directly
no test coverage detected
searching dependent graphs…