(t *testing.T)
| 71 | } |
| 72 | |
| 73 | func TestVolumeInspectWithoutFormat(t *testing.T) { |
| 74 | testCases := []struct { |
| 75 | name string |
| 76 | args []string |
| 77 | volumeInspectFunc func(volumeID string) (client.VolumeInspectResult, error) |
| 78 | }{ |
| 79 | { |
| 80 | name: "single-volume", |
| 81 | args: []string{"foo"}, |
| 82 | volumeInspectFunc: func(volumeID string) (client.VolumeInspectResult, error) { |
| 83 | if volumeID != "foo" { |
| 84 | return client.VolumeInspectResult{}, fmt.Errorf("invalid volumeID, expected %s, got %s", "foo", volumeID) |
| 85 | } |
| 86 | return client.VolumeInspectResult{ |
| 87 | Volume: builders.Volume(), |
| 88 | }, nil |
| 89 | }, |
| 90 | }, |
| 91 | { |
| 92 | name: "multiple-volume-with-labels", |
| 93 | args: []string{"foo", "bar"}, |
| 94 | volumeInspectFunc: func(volumeID string) (client.VolumeInspectResult, error) { |
| 95 | return client.VolumeInspectResult{ |
| 96 | Volume: builders.Volume(builders.VolumeName(volumeID), builders.VolumeLabels(map[string]string{ |
| 97 | "foo": "bar", |
| 98 | })), |
| 99 | }, nil |
| 100 | }, |
| 101 | }, |
| 102 | } |
| 103 | for _, tc := range testCases { |
| 104 | cli := test.NewFakeCli(&fakeClient{ |
| 105 | volumeInspectFunc: tc.volumeInspectFunc, |
| 106 | }) |
| 107 | cmd := newInspectCommand(cli) |
| 108 | cmd.SetArgs(tc.args) |
| 109 | assert.NilError(t, cmd.Execute()) |
| 110 | golden.Assert(t, cli.OutBuffer().String(), fmt.Sprintf("volume-inspect-without-format.%s.golden", tc.name)) |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | func TestVolumeInspectWithFormat(t *testing.T) { |
| 115 | volumeInspectFunc := func(volumeID string) (client.VolumeInspectResult, error) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…