(t *testing.T)
| 56 | } |
| 57 | |
| 58 | func TestSecretCreateWithName(t *testing.T) { |
| 59 | const name = "secret-with-name" |
| 60 | data, err := os.ReadFile(filepath.Join("testdata", secretDataFile)) |
| 61 | assert.NilError(t, err) |
| 62 | |
| 63 | expected := swarm.SecretSpec{ |
| 64 | Annotations: swarm.Annotations{ |
| 65 | Name: name, |
| 66 | Labels: make(map[string]string), |
| 67 | }, |
| 68 | Data: data, |
| 69 | } |
| 70 | |
| 71 | cli := test.NewFakeCli(&fakeClient{ |
| 72 | secretCreateFunc: func(_ context.Context, options client.SecretCreateOptions) (client.SecretCreateResult, error) { |
| 73 | if !reflect.DeepEqual(options.Spec, expected) { |
| 74 | return client.SecretCreateResult{}, fmt.Errorf("expected %+v, got %+v", expected, options.Spec) |
| 75 | } |
| 76 | return client.SecretCreateResult{ |
| 77 | ID: "ID-" + options.Spec.Name, |
| 78 | }, nil |
| 79 | }, |
| 80 | }) |
| 81 | |
| 82 | cmd := newSecretCreateCommand(cli) |
| 83 | cmd.SetArgs([]string{name, filepath.Join("testdata", secretDataFile)}) |
| 84 | assert.NilError(t, cmd.Execute()) |
| 85 | assert.Check(t, is.Equal("ID-"+name, strings.TrimSpace(cli.OutBuffer().String()))) |
| 86 | } |
| 87 | |
| 88 | func TestSecretCreateWithDriver(t *testing.T) { |
| 89 | expectedDriver := &swarm.Driver{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…