(t *testing.T)
| 121 | } |
| 122 | |
| 123 | func TestConfigCreateWithTemplatingDriver(t *testing.T) { |
| 124 | expectedDriver := &swarm.Driver{ |
| 125 | Name: "template-driver", |
| 126 | } |
| 127 | const name = "config-with-template-driver" |
| 128 | |
| 129 | cli := test.NewFakeCli(&fakeClient{ |
| 130 | configCreateFunc: func(_ context.Context, options client.ConfigCreateOptions) (client.ConfigCreateResult, error) { |
| 131 | if options.Spec.Name != name { |
| 132 | return client.ConfigCreateResult{}, fmt.Errorf("expected name %q, got %q", name, options.Spec.Name) |
| 133 | } |
| 134 | |
| 135 | if options.Spec.Templating.Name != expectedDriver.Name { |
| 136 | return client.ConfigCreateResult{}, fmt.Errorf("expected driver %v, got %v", expectedDriver, options.Spec.Labels) |
| 137 | } |
| 138 | |
| 139 | return client.ConfigCreateResult{ |
| 140 | ID: "ID-" + options.Spec.Name, |
| 141 | }, nil |
| 142 | }, |
| 143 | }) |
| 144 | |
| 145 | cmd := newConfigCreateCommand(cli) |
| 146 | cmd.SetArgs([]string{name, filepath.Join("testdata", configDataFile)}) |
| 147 | cmd.Flags().Set("template-driver", expectedDriver.Name) |
| 148 | assert.NilError(t, cmd.Execute()) |
| 149 | assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String()))) |
| 150 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…