(t *testing.T)
| 75 | } |
| 76 | |
| 77 | func 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 |
| 95 | networkID1 foobar_baz foo local |
| 96 | networkID2 foobar_bar bar local |
| 97 | `, |
| 98 | }, |
| 99 | { |
| 100 | formatter.Context{Format: newFormat("table", true)}, |
| 101 | `networkID1 |
| 102 | networkID2 |
| 103 | `, |
| 104 | }, |
| 105 | { |
| 106 | formatter.Context{Format: newFormat("table {{.Name}}", false)}, |
| 107 | `NAME |
| 108 | foobar_baz |
| 109 | foobar_bar |
| 110 | `, |
| 111 | }, |
| 112 | { |
| 113 | formatter.Context{Format: newFormat("table {{.Name}}", true)}, |
| 114 | `NAME |
| 115 | foobar_baz |
| 116 | foobar_bar |
| 117 | `, |
| 118 | }, |
| 119 | // Raw Format |
| 120 | { |
| 121 | formatter.Context{Format: newFormat("raw", false)}, |
| 122 | `network_id: networkID1 |
| 123 | name: foobar_baz |
| 124 | driver: foo |
| 125 | scope: local |
| 126 | |
| 127 | network_id: networkID2 |
| 128 | name: foobar_bar |
| 129 | driver: bar |
| 130 | scope: local |
| 131 | |
| 132 | `, |
| 133 | }, |
| 134 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…