MCPcopy Create free account
hub / github.com/docker/cli / TestVolumeInspectWithFormat

Function TestVolumeInspectWithFormat

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

Source from the content-addressed store, hash-verified

112}
113
114func 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
153func TestVolumeInspectCluster(t *testing.T) {
154 volumeInspectFunc := func(volumeID string) (client.VolumeInspectResult, error) {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…