(t *testing.T)
| 112 | } |
| 113 | |
| 114 | func TestListRun(t *testing.T) { |
| 115 | tests := []struct { |
| 116 | name string |
| 117 | opts *listOptions |
| 118 | isTTY bool |
| 119 | stubLister stubAutolinkLister |
| 120 | expectedErr error |
| 121 | wantStdout string |
| 122 | wantStderr string |
| 123 | }{ |
| 124 | { |
| 125 | name: "list tty", |
| 126 | opts: &listOptions{}, |
| 127 | isTTY: true, |
| 128 | stubLister: stubAutolinkLister{ |
| 129 | autolinks: []shared.Autolink{ |
| 130 | { |
| 131 | ID: 1, |
| 132 | KeyPrefix: "TICKET-", |
| 133 | URLTemplate: "https://example.com/TICKET?query=<num>", |
| 134 | IsAlphanumeric: true, |
| 135 | }, |
| 136 | { |
| 137 | ID: 2, |
| 138 | KeyPrefix: "STORY-", |
| 139 | URLTemplate: "https://example.com/STORY?id=<num>", |
| 140 | IsAlphanumeric: false, |
| 141 | }, |
| 142 | }, |
| 143 | }, |
| 144 | wantStdout: heredoc.Doc(` |
| 145 | |
| 146 | Showing 2 autolink references in OWNER/REPO |
| 147 | |
| 148 | ID KEY PREFIX URL TEMPLATE ALPHANUMERIC |
| 149 | 1 TICKET- https://example.com/TICKET?query=<num> true |
| 150 | 2 STORY- https://example.com/STORY?id=<num> false |
| 151 | `), |
| 152 | wantStderr: "", |
| 153 | }, |
| 154 | { |
| 155 | name: "list json", |
| 156 | opts: &listOptions{ |
| 157 | Exporter: func() cmdutil.Exporter { |
| 158 | exporter := cmdutil.NewJSONExporter() |
| 159 | exporter.SetFields([]string{"id"}) |
| 160 | return exporter |
| 161 | }(), |
| 162 | }, |
| 163 | isTTY: true, |
| 164 | stubLister: stubAutolinkLister{ |
| 165 | autolinks: []shared.Autolink{ |
| 166 | { |
| 167 | ID: 1, |
| 168 | KeyPrefix: "TICKET-", |
| 169 | URLTemplate: "https://example.com/TICKET?query=<num>", |
| 170 | IsAlphanumeric: true, |
| 171 | }, |
nothing calls this directly
no test coverage detected