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

Function TestVolumeContextWrite

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

Source from the content-addressed store, hash-verified

55}
56
57func TestVolumeContextWrite(t *testing.T) {
58 cases := []struct {
59 context Context
60 expected string
61 }{
62 // Errors
63 {
64 Context{Format: "{{InvalidFunction}}"},
65 `template parsing error: template: :1: function "InvalidFunction" not defined`,
66 },
67 {
68 Context{Format: "{{nil}}"},
69 `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
70 },
71 // Table format
72 {
73 Context{Format: NewVolumeFormat("table", false)},
74 `DRIVER VOLUME NAME
75foo foobar_baz
76bar foobar_bar
77`,
78 },
79 {
80 Context{Format: NewVolumeFormat("table", true)},
81 `foobar_baz
82foobar_bar
83`,
84 },
85 {
86 Context{Format: NewVolumeFormat("table {{.Name}}", false)},
87 `VOLUME NAME
88foobar_baz
89foobar_bar
90`,
91 },
92 {
93 Context{Format: NewVolumeFormat("table {{.Name}}", true)},
94 `VOLUME NAME
95foobar_baz
96foobar_bar
97`,
98 },
99 // Raw Format
100 {
101 Context{Format: NewVolumeFormat("raw", false)},
102 `name: foobar_baz
103driver: foo
104
105name: foobar_bar
106driver: bar
107
108`,
109 },
110 {
111 Context{Format: NewVolumeFormat("raw", true)},
112 `name: foobar_baz
113name: foobar_bar
114`,

Callers

nothing calls this directly

Calls 4

NewVolumeFormatFunction · 0.85
VolumeWriteFunction · 0.85
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…