(t *testing.T)
| 218 | } |
| 219 | |
| 220 | func TestRunCreate_Me(t *testing.T) { |
| 221 | defer gock.Off() |
| 222 | gock.Observe(gock.DumpRequest) |
| 223 | // get viewer ID |
| 224 | gock.New("https://api.github.com"). |
| 225 | Post("/graphql"). |
| 226 | MatchType("json"). |
| 227 | JSON(map[string]interface{}{ |
| 228 | "query": "query ViewerOwner.*", |
| 229 | }). |
| 230 | Reply(200). |
| 231 | JSON(map[string]interface{}{ |
| 232 | "data": map[string]interface{}{ |
| 233 | "viewer": map[string]interface{}{ |
| 234 | "id": "an ID", |
| 235 | "login": "me", |
| 236 | }, |
| 237 | }, |
| 238 | }) |
| 239 | |
| 240 | // create project |
| 241 | gock.New("https://api.github.com"). |
| 242 | Post("/graphql"). |
| 243 | BodyString(`{"query":"mutation CreateProjectV2.*"variables":{"afterFields":null,"afterItems":null,"firstFields":0,"firstItems":0,"input":{"ownerId":"an ID","title":"a title"}}}`).Reply(200). |
| 244 | JSON(map[string]interface{}{ |
| 245 | "data": map[string]interface{}{ |
| 246 | "createProjectV2": map[string]interface{}{ |
| 247 | "projectV2": map[string]interface{}{ |
| 248 | "title": "a title", |
| 249 | "url": "http://a-url.com", |
| 250 | "owner": map[string]string{ |
| 251 | "login": "me", |
| 252 | }, |
| 253 | }, |
| 254 | }, |
| 255 | }, |
| 256 | }) |
| 257 | |
| 258 | client := queries.NewTestClient() |
| 259 | |
| 260 | ios, _, stdout, _ := iostreams.Test() |
| 261 | ios.SetStdoutTTY(true) |
| 262 | config := createConfig{ |
| 263 | opts: createOpts{ |
| 264 | title: "a title", |
| 265 | owner: "@me", |
| 266 | }, |
| 267 | client: client, |
| 268 | io: ios, |
| 269 | } |
| 270 | |
| 271 | err := runCreate(config) |
| 272 | assert.NoError(t, err) |
| 273 | assert.Equal( |
| 274 | t, |
| 275 | "http://a-url.com\n", |
| 276 | stdout.String()) |
| 277 | } |
nothing calls this directly
no test coverage detected