MCPcopy Index your code
hub / github.com/docker/cli / TestBuildWithBuilder

Function TestBuildWithBuilder

cmd/docker/builder_test.go:24–122  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22var pluginFilename = "docker-buildx"
23
24func TestBuildWithBuilder(t *testing.T) {
25 ctx := t.Context()
26
27 testcases := []struct {
28 name string
29 context string
30 builder string
31 alias bool
32 expectedEnvs []string
33 }{
34 {
35 name: "default",
36 context: "default",
37 alias: false,
38 expectedEnvs: []string{"BUILDX_BUILDER=default"},
39 },
40 {
41 name: "custom context",
42 context: "foo",
43 alias: false,
44 expectedEnvs: []string{"BUILDX_BUILDER=foo"},
45 },
46 {
47 name: "custom builder name",
48 builder: "mybuilder",
49 alias: false,
50 expectedEnvs: nil,
51 },
52 {
53 name: "buildx install",
54 alias: true,
55 expectedEnvs: nil,
56 },
57 }
58
59 dir := fs.NewDir(t, t.Name(),
60 fs.WithFile(pluginFilename, `#!/bin/sh
61echo '{"SchemaVersion":"0.1.0","Vendor":"Docker Inc.","Version":"v0.6.3","ShortDescription":"Build with BuildKit"}'`, fs.WithMode(0o777)),
62 )
63 defer dir.Remove()
64
65 for _, tc := range testcases {
66 t.Run(tc.name, func(t *testing.T) {
67 ctx2, cancel2 := context.WithCancel(ctx)
68 defer cancel2()
69
70 if tc.builder != "" {
71 t.Setenv("BUILDX_BUILDER", tc.builder)
72 }
73
74 var b bytes.Buffer
75 dockerCli, err := command.NewDockerCli(
76 command.WithBaseContext(ctx2),
77 command.WithAPIClient(&fakeClient{}),
78 command.WithInputStream(discard),
79 command.WithCombinedStreams(&b),
80 )
81 assert.NilError(t, err)

Callers

nothing calls this directly

Calls 11

InitializeMethod · 0.95
ContextStoreMethod · 0.95
ConfigFileMethod · 0.95
newDockerCommandFunction · 0.85
processBuilderFunction · 0.85
SetArgsMethod · 0.80
HandleGlobalFlagsMethod · 0.80
RemoveMethod · 0.65
CreateOrUpdateMethod · 0.65
PathMethod · 0.65
NameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…