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