(t *testing.T)
| 22 | const configDataFile = "config-create-with-name.golden" |
| 23 | |
| 24 | func TestConfigCreateErrors(t *testing.T) { |
| 25 | testCases := []struct { |
| 26 | args []string |
| 27 | configCreateFunc func(context.Context, client.ConfigCreateOptions) (client.ConfigCreateResult, error) |
| 28 | expectedError string |
| 29 | }{ |
| 30 | { |
| 31 | args: []string{"too_few"}, |
| 32 | expectedError: "requires 2 arguments", |
| 33 | }, |
| 34 | { |
| 35 | args: []string{"too", "many", "arguments"}, |
| 36 | expectedError: "requires 2 arguments", |
| 37 | }, |
| 38 | { |
| 39 | args: []string{"name", filepath.Join("testdata", configDataFile)}, |
| 40 | configCreateFunc: func(_ context.Context, options client.ConfigCreateOptions) (client.ConfigCreateResult, error) { |
| 41 | return client.ConfigCreateResult{}, errors.New("error creating config") |
| 42 | }, |
| 43 | expectedError: "error creating config", |
| 44 | }, |
| 45 | } |
| 46 | for _, tc := range testCases { |
| 47 | t.Run(tc.expectedError, func(t *testing.T) { |
| 48 | cmd := newConfigCreateCommand( |
| 49 | test.NewFakeCli(&fakeClient{ |
| 50 | configCreateFunc: tc.configCreateFunc, |
| 51 | }), |
| 52 | ) |
| 53 | cmd.SetArgs(tc.args) |
| 54 | cmd.SetOut(io.Discard) |
| 55 | cmd.SetErr(io.Discard) |
| 56 | assert.ErrorContains(t, cmd.Execute(), tc.expectedError) |
| 57 | }) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | func TestConfigCreateWithName(t *testing.T) { |
| 62 | const name = "config-with-name" |
nothing calls this directly
no test coverage detected
searching dependent graphs…