(t *testing.T)
| 70 | } |
| 71 | |
| 72 | func TestPluginContextWrite(t *testing.T) { |
| 73 | tests := []struct { |
| 74 | doc string |
| 75 | context formatter.Context |
| 76 | expected string |
| 77 | }{ |
| 78 | { |
| 79 | doc: "invalid function", |
| 80 | context: formatter.Context{Format: "{{InvalidFunction}}"}, |
| 81 | expected: `template parsing error: template: :1: function "InvalidFunction" not defined`, |
| 82 | }, |
| 83 | { |
| 84 | doc: "nil template", |
| 85 | context: formatter.Context{Format: "{{nil}}"}, |
| 86 | expected: `template parsing error: template: :1:2: executing "" at <nil>: nil is not a command`, |
| 87 | }, |
| 88 | { |
| 89 | doc: "table format", |
| 90 | context: formatter.Context{Format: newFormat("table", false)}, |
| 91 | expected: `ID NAME DESCRIPTION ENABLED |
| 92 | pluginID1 foobar_baz description 1 true |
| 93 | pluginID2 foobar_bar description 2 false |
| 94 | `, |
| 95 | }, |
| 96 | { |
| 97 | doc: "table format, quiet", |
| 98 | context: formatter.Context{Format: newFormat("table", true)}, |
| 99 | expected: `pluginID1 |
| 100 | pluginID2 |
| 101 | `, |
| 102 | }, |
| 103 | { |
| 104 | doc: "table format name col", |
| 105 | context: formatter.Context{Format: newFormat("table {{.Name}}", false)}, |
| 106 | expected: `NAME |
| 107 | foobar_baz |
| 108 | foobar_bar |
| 109 | `, |
| 110 | }, |
| 111 | { |
| 112 | doc: "table format name col, quiet", |
| 113 | context: formatter.Context{Format: newFormat("table {{.Name}}", true)}, |
| 114 | expected: `NAME |
| 115 | foobar_baz |
| 116 | foobar_bar |
| 117 | `, |
| 118 | }, |
| 119 | { |
| 120 | doc: "raw format", |
| 121 | context: formatter.Context{Format: newFormat("raw", false)}, |
| 122 | expected: `plugin_id: pluginID1 |
| 123 | name: foobar_baz |
| 124 | description: description 1 |
| 125 | enabled: true |
| 126 | |
| 127 | plugin_id: pluginID2 |
| 128 | name: foobar_bar |
| 129 | description: description 2 |
nothing calls this directly
no test coverage detected
searching dependent graphs…