(t *testing.T)
| 69 | } |
| 70 | |
| 71 | func TestConfigInspectWithoutFormat(t *testing.T) { |
| 72 | testCases := []struct { |
| 73 | name string |
| 74 | args []string |
| 75 | configInspectFunc func(_ context.Context, configID string, _ client.ConfigInspectOptions) (client.ConfigInspectResult, error) |
| 76 | }{ |
| 77 | { |
| 78 | name: "single-config", |
| 79 | args: []string{"foo"}, |
| 80 | configInspectFunc: func(_ context.Context, name string, _ client.ConfigInspectOptions) (client.ConfigInspectResult, error) { |
| 81 | if name != "foo" { |
| 82 | return client.ConfigInspectResult{}, fmt.Errorf("invalid name, expected %s, got %s", "foo", name) |
| 83 | } |
| 84 | return client.ConfigInspectResult{ |
| 85 | Config: *builders.Config( |
| 86 | builders.ConfigID("ID-foo"), |
| 87 | builders.ConfigName("foo"), |
| 88 | ), |
| 89 | }, nil |
| 90 | }, |
| 91 | }, |
| 92 | { |
| 93 | name: "multiple-configs-with-labels", |
| 94 | args: []string{"foo", "bar"}, |
| 95 | configInspectFunc: func(_ context.Context, name string, _ client.ConfigInspectOptions) (client.ConfigInspectResult, error) { |
| 96 | return client.ConfigInspectResult{ |
| 97 | Config: *builders.Config( |
| 98 | builders.ConfigID("ID-"+name), |
| 99 | builders.ConfigName(name), |
| 100 | builders.ConfigLabels(map[string]string{"label1": "label-foo"}), |
| 101 | ), |
| 102 | }, nil |
| 103 | }, |
| 104 | }, |
| 105 | } |
| 106 | for _, tc := range testCases { |
| 107 | cli := test.NewFakeCli(&fakeClient{configInspectFunc: tc.configInspectFunc}) |
| 108 | cmd := newConfigInspectCommand(cli) |
| 109 | cmd.SetArgs(tc.args) |
| 110 | assert.NilError(t, cmd.Execute()) |
| 111 | golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("config-inspect-without-format.%s.golden", tc.name)) |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | func TestConfigInspectWithFormat(t *testing.T) { |
| 116 | configInspectFunc := func(_ context.Context, name string, _ client.ConfigInspectOptions) (client.ConfigInspectResult, error) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…