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

Function TestVolumeContextWriteJSONField

cli/command/formatter/volume_test.go:167–184  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

165}
166
167func TestVolumeContextWriteJSONField(t *testing.T) {
168 volumes := []volume.Volume{
169 {Driver: "foo", Name: "foobar_baz"},
170 {Driver: "bar", Name: "foobar_bar"},
171 }
172 out := bytes.NewBufferString("")
173 err := VolumeWrite(Context{Format: "{{json .Name}}", Output: out}, volumes)
174 if err != nil {
175 t.Fatal(err)
176 }
177 for i, line := range strings.Split(strings.TrimSpace(out.String()), "\n") {
178 msg := fmt.Sprintf("Output: line %d: %s", i, line)
179 var s string
180 err := json.Unmarshal([]byte(line), &s)
181 assert.NilError(t, err, msg)
182 assert.Check(t, is.Equal(volumes[i].Name, s), msg)
183 }
184}

Callers

nothing calls this directly

Calls 2

VolumeWriteFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…