(t *testing.T)
| 98 | } |
| 99 | |
| 100 | func TestListRun(t *testing.T) { |
| 101 | now := time.Date(2026, 1, 2, 3, 0, 0, 0, time.UTC) |
| 102 | subs := []client.Subscription{ |
| 103 | { |
| 104 | ID: "sub_2", |
| 105 | ResourceURL: "https://github.com/OWNER/REPO/pull/2", |
| 106 | EventTypes: []string{"test.a", "test.b"}, |
| 107 | ExpiresAt: now.Add(23 * time.Hour), |
| 108 | }, |
| 109 | { |
| 110 | ID: "sub_1", |
| 111 | ResourceURL: "https://github.com/OWNER/REPO/pull/1", |
| 112 | EventTypes: []string{"test.a"}, |
| 113 | ExpiresAt: now.Add(30 * time.Minute), |
| 114 | }, |
| 115 | } |
| 116 | |
| 117 | tests := []struct { |
| 118 | name string |
| 119 | tty bool |
| 120 | jsonFields []string |
| 121 | subs []client.Subscription |
| 122 | listErr error |
| 123 | wantOut string |
| 124 | wantErr string |
| 125 | wantNoRes bool |
| 126 | }{ |
| 127 | { |
| 128 | name: "tty", |
| 129 | tty: true, |
| 130 | subs: subs, |
| 131 | wantOut: "\n" + heredoc.Doc(` |
| 132 | Showing 2 event subscriptions |
| 133 | |
| 134 | ID RESOURCE EVENTS EXPIRES |
| 135 | sub_2 https://github.com/OWNER/REPO/pull/2 test.a, test.b in about 23 hours |
| 136 | sub_1 https://github.com/OWNER/REPO/pull/1 test.a in about 30 minutes |
| 137 | `), |
| 138 | }, |
| 139 | { |
| 140 | name: "not tty", |
| 141 | subs: subs, |
| 142 | wantOut: heredoc.Doc(` |
| 143 | sub_2 https://github.com/OWNER/REPO/pull/2 test.a,test.b 2026-01-03T02:00:00Z |
| 144 | sub_1 https://github.com/OWNER/REPO/pull/1 test.a 2026-01-02T03:30:00Z |
| 145 | `), |
| 146 | }, |
| 147 | { |
| 148 | name: "no subscriptions", |
| 149 | tty: true, |
| 150 | subs: []client.Subscription{}, |
| 151 | wantNoRes: true, |
| 152 | }, |
| 153 | { |
| 154 | name: "json", |
| 155 | jsonFields: []string{"id", "eventTypes"}, |
| 156 | subs: subs, |
| 157 | wantOut: `[{"eventTypes":["test.a","test.b"],"id":"sub_2"},{"eventTypes":["test.a"],"id":"sub_1"}]` + "\n", |
nothing calls this directly
no test coverage detected