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