(t *testing.T)
| 113 | } |
| 114 | |
| 115 | func TestConfigInspectWithFormat(t *testing.T) { |
| 116 | configInspectFunc := func(_ context.Context, name string, _ client.ConfigInspectOptions) (client.ConfigInspectResult, error) { |
| 117 | return client.ConfigInspectResult{ |
| 118 | Config: *builders.Config( |
| 119 | builders.ConfigName("foo"), |
| 120 | builders.ConfigLabels(map[string]string{"label1": "label-foo"}), |
| 121 | ), |
| 122 | }, nil |
| 123 | } |
| 124 | testCases := []struct { |
| 125 | name string |
| 126 | format string |
| 127 | args []string |
| 128 | configInspectFunc func(_ context.Context, name string, _ client.ConfigInspectOptions) (client.ConfigInspectResult, error) |
| 129 | }{ |
| 130 | { |
| 131 | name: "simple-template", |
| 132 | format: "{{.Spec.Name}}", |
| 133 | args: []string{"foo"}, |
| 134 | configInspectFunc: configInspectFunc, |
| 135 | }, |
| 136 | { |
| 137 | name: "json-template", |
| 138 | format: "{{json .Spec.Labels}}", |
| 139 | args: []string{"foo"}, |
| 140 | configInspectFunc: configInspectFunc, |
| 141 | }, |
| 142 | } |
| 143 | for _, tc := range testCases { |
| 144 | cli := test.NewFakeCli(&fakeClient{ |
| 145 | configInspectFunc: tc.configInspectFunc, |
| 146 | }) |
| 147 | cmd := newConfigInspectCommand(cli) |
| 148 | cmd.SetArgs(tc.args) |
| 149 | assert.Check(t, cmd.Flags().Set("format", tc.format)) |
| 150 | assert.NilError(t, cmd.Execute()) |
| 151 | golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("config-inspect-with-format.%s.golden", tc.name)) |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | func TestConfigInspectPretty(t *testing.T) { |
| 156 | testCases := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…