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

Function TestNetworkContextWrite

cli/command/network/formatter_test.go:77–194  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

75}
76
77func TestNetworkContextWrite(t *testing.T) {
78 cases := []struct {
79 context formatter.Context
80 expected string
81 }{
82 // Errors
83 {
84 formatter.Context{Format: "{{InvalidFunction}}"},
85 `template parsing error: template: :1: function "InvalidFunction" not defined`,
86 },
87 {
88 formatter.Context{Format: "{{nil}}"},
89 `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`,
90 },
91 // Table format
92 {
93 formatter.Context{Format: newFormat("table", false)},
94 `NETWORK ID NAME DRIVER SCOPE
95networkID1 foobar_baz foo local
96networkID2 foobar_bar bar local
97`,
98 },
99 {
100 formatter.Context{Format: newFormat("table", true)},
101 `networkID1
102networkID2
103`,
104 },
105 {
106 formatter.Context{Format: newFormat("table {{.Name}}", false)},
107 `NAME
108foobar_baz
109foobar_bar
110`,
111 },
112 {
113 formatter.Context{Format: newFormat("table {{.Name}}", true)},
114 `NAME
115foobar_baz
116foobar_bar
117`,
118 },
119 // Raw Format
120 {
121 formatter.Context{Format: newFormat("raw", false)},
122 `network_id: networkID1
123name: foobar_baz
124driver: foo
125scope: local
126
127network_id: networkID2
128name: foobar_bar
129driver: bar
130scope: local
131
132`,
133 },
134 {

Callers

nothing calls this directly

Calls 4

newFormatFunction · 0.70
formatWriteFunction · 0.70
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…