(t *testing.T)
| 83 | } |
| 84 | |
| 85 | func TestConfigCreateWithLabels(t *testing.T) { |
| 86 | expectedLabels := map[string]string{ |
| 87 | "lbl1": "Label-foo", |
| 88 | "lbl2": "Label-bar", |
| 89 | } |
| 90 | const name = "config-with-labels" |
| 91 | |
| 92 | data, err := os.ReadFile(filepath.Join("testdata", configDataFile)) |
| 93 | assert.NilError(t, err) |
| 94 | |
| 95 | expected := swarm.ConfigSpec{ |
| 96 | Annotations: swarm.Annotations{ |
| 97 | Name: name, |
| 98 | Labels: expectedLabels, |
| 99 | }, |
| 100 | Data: data, |
| 101 | } |
| 102 | |
| 103 | cli := test.NewFakeCli(&fakeClient{ |
| 104 | configCreateFunc: func(_ context.Context, options client.ConfigCreateOptions) (client.ConfigCreateResult, error) { |
| 105 | if !reflect.DeepEqual(options.Spec, expected) { |
| 106 | return client.ConfigCreateResult{}, fmt.Errorf("expected %+v, got %+v", expected, options.Spec) |
| 107 | } |
| 108 | |
| 109 | return client.ConfigCreateResult{ |
| 110 | ID: "ID-" + options.Spec.Name, |
| 111 | }, nil |
| 112 | }, |
| 113 | }) |
| 114 | |
| 115 | cmd := newConfigCreateCommand(cli) |
| 116 | cmd.SetArgs([]string{name, filepath.Join("testdata", configDataFile)}) |
| 117 | cmd.Flags().Set("label", "lbl1=Label-foo") |
| 118 | cmd.Flags().Set("label", "lbl2=Label-bar") |
| 119 | assert.NilError(t, cmd.Execute()) |
| 120 | assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String()))) |
| 121 | } |
| 122 | |
| 123 | func TestConfigCreateWithTemplatingDriver(t *testing.T) { |
| 124 | expectedDriver := &swarm.Driver{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…