MCPcopy Index your code
hub / github.com/docker/cli / TestVolumeInspectWithoutFormat

Function TestVolumeInspectWithoutFormat

cli/command/volume/inspect_test.go:73–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func 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
114func TestVolumeInspectWithFormat(t *testing.T) {
115 volumeInspectFunc := func(volumeID string) (client.VolumeInspectResult, error) {

Callers

nothing calls this directly

Calls 4

OutBufferMethod · 0.95
SetArgsMethod · 0.80
newInspectCommandFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…