(t *testing.T)
| 144 | } |
| 145 | |
| 146 | func TestSecretCreateWithLabels(t *testing.T) { |
| 147 | expectedLabels := map[string]string{ |
| 148 | "lbl1": "Label-foo", |
| 149 | "lbl2": "Label-bar", |
| 150 | } |
| 151 | const name = "secret-with-labels" |
| 152 | |
| 153 | cli := test.NewFakeCli(&fakeClient{ |
| 154 | secretCreateFunc: func(_ context.Context, options client.SecretCreateOptions) (client.SecretCreateResult, error) { |
| 155 | if options.Spec.Name != name { |
| 156 | return client.SecretCreateResult{}, fmt.Errorf("expected name %q, got %q", name, options.Spec.Name) |
| 157 | } |
| 158 | |
| 159 | if !reflect.DeepEqual(options.Spec.Labels, expectedLabels) { |
| 160 | return client.SecretCreateResult{}, fmt.Errorf("expected labels %v, got %v", expectedLabels, options.Spec.Labels) |
| 161 | } |
| 162 | |
| 163 | return client.SecretCreateResult{ |
| 164 | ID: "ID-" + options.Spec.Name, |
| 165 | }, nil |
| 166 | }, |
| 167 | }) |
| 168 | |
| 169 | cmd := newSecretCreateCommand(cli) |
| 170 | cmd.SetArgs([]string{name, filepath.Join("testdata", secretDataFile)}) |
| 171 | assert.Check(t, cmd.Flags().Set("label", "lbl1=Label-foo")) |
| 172 | assert.Check(t, cmd.Flags().Set("label", "lbl2=Label-bar")) |
| 173 | assert.NilError(t, cmd.Execute()) |
| 174 | assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String()))) |
| 175 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…