MCPcopy Create free account
hub / github.com/containerd/nerdctl / TestBuildWithDockerfile

Function TestBuildWithDockerfile

cmd/nerdctl/builder/builder_build_test.go:268–319  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

266}
267
268func TestBuildWithDockerfile(t *testing.T) {
269 nerdtest.Setup()
270
271 dockerfile := fmt.Sprintf(`FROM %s
272CMD ["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
321func TestBuildLocal(t *testing.T) {
322 nerdtest.Setup()

Callers

nothing calls this directly

Calls 12

RunMethod · 0.95
SetupFunction · 0.92
SaveMethod · 0.65
TempMethod · 0.65
SetMethod · 0.65
LabelsMethod · 0.65
PathMethod · 0.65
AnyhowMethod · 0.65
IdentifierMethod · 0.65
CommandMethod · 0.65
WithCwdMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…