(t *testing.T)
| 130 | } |
| 131 | |
| 132 | func Test_listRun(t *testing.T) { |
| 133 | const query = `query GistList\b` |
| 134 | sixHours, _ := time.ParseDuration("6h") |
| 135 | sixHoursAgo := time.Now().Add(-sixHours) |
| 136 | absTime, _ := time.Parse(time.RFC3339, "2020-07-30T15:24:28Z") |
| 137 | |
| 138 | tests := []struct { |
| 139 | name string |
| 140 | opts *ListOptions |
| 141 | wantErr bool |
| 142 | wantOut string |
| 143 | stubs func(*httpmock.Registry) |
| 144 | color bool |
| 145 | nontty bool |
| 146 | }{ |
| 147 | { |
| 148 | name: "no gists", |
| 149 | opts: &ListOptions{}, |
| 150 | stubs: func(reg *httpmock.Registry) { |
| 151 | reg.Register( |
| 152 | httpmock.GraphQL(query), |
| 153 | httpmock.StringResponse(`{ "data": { "viewer": { |
| 154 | "gists": { "nodes": [] } |
| 155 | } } }`)) |
| 156 | }, |
| 157 | wantErr: true, |
| 158 | }, |
| 159 | { |
| 160 | name: "default behavior", |
| 161 | opts: &ListOptions{}, |
| 162 | stubs: func(reg *httpmock.Registry) { |
| 163 | reg.Register( |
| 164 | httpmock.GraphQL(query), |
| 165 | httpmock.StringResponse(fmt.Sprintf( |
| 166 | `{ "data": { "viewer": { "gists": { "nodes": [ |
| 167 | { |
| 168 | "name": "1234567890", |
| 169 | "files": [{ "name": "cool.txt" }], |
| 170 | "description": "", |
| 171 | "updatedAt": "%[1]v", |
| 172 | "isPublic": true |
| 173 | }, |
| 174 | { |
| 175 | "name": "4567890123", |
| 176 | "files": [{ "name": "gistfile0.txt" }], |
| 177 | "description": "", |
| 178 | "updatedAt": "%[1]v", |
| 179 | "isPublic": true |
| 180 | }, |
| 181 | { |
| 182 | "name": "2345678901", |
| 183 | "files": [ |
| 184 | { "name": "gistfile0.txt" }, |
| 185 | { "name": "gistfile1.txt" } |
| 186 | ], |
| 187 | "description": "tea leaves thwart those who court catastrophe", |
| 188 | "updatedAt": "%[1]v", |
| 189 | "isPublic": false |
nothing calls this directly
no test coverage detected