(t *testing.T)
| 150 | } |
| 151 | |
| 152 | func TestRunCreate_Org(t *testing.T) { |
| 153 | defer gock.Off() |
| 154 | gock.Observe(gock.DumpRequest) |
| 155 | // get org ID |
| 156 | gock.New("https://api.github.com"). |
| 157 | Post("/graphql"). |
| 158 | MatchType("json"). |
| 159 | JSON(map[string]interface{}{ |
| 160 | "query": "query UserOrgOwner.*", |
| 161 | "variables": map[string]string{ |
| 162 | "login": "github", |
| 163 | }, |
| 164 | }). |
| 165 | Reply(200). |
| 166 | JSON(map[string]interface{}{ |
| 167 | "data": map[string]interface{}{ |
| 168 | "organization": map[string]interface{}{ |
| 169 | "id": "an ID", |
| 170 | "login": "github", |
| 171 | }, |
| 172 | }, |
| 173 | "errors": []interface{}{ |
| 174 | map[string]interface{}{ |
| 175 | "type": "NOT_FOUND", |
| 176 | "path": []string{"user"}, |
| 177 | }, |
| 178 | }, |
| 179 | }) |
| 180 | |
| 181 | // create project |
| 182 | gock.New("https://api.github.com"). |
| 183 | Post("/graphql"). |
| 184 | BodyString(`{"query":"mutation CreateProjectV2.*"variables":{"afterFields":null,"afterItems":null,"firstFields":0,"firstItems":0,"input":{"ownerId":"an ID","title":"a title"}}}`).Reply(200). |
| 185 | JSON(map[string]interface{}{ |
| 186 | "data": map[string]interface{}{ |
| 187 | "createProjectV2": map[string]interface{}{ |
| 188 | "projectV2": map[string]interface{}{ |
| 189 | "title": "a title", |
| 190 | "url": "http://a-url.com", |
| 191 | "owner": map[string]string{ |
| 192 | "login": "monalisa", |
| 193 | }, |
| 194 | }, |
| 195 | }, |
| 196 | }, |
| 197 | }) |
| 198 | |
| 199 | client := queries.NewTestClient() |
| 200 | |
| 201 | ios, _, stdout, _ := iostreams.Test() |
| 202 | ios.SetStdoutTTY(true) |
| 203 | config := createConfig{ |
| 204 | opts: createOpts{ |
| 205 | title: "a title", |
| 206 | owner: "github", |
| 207 | }, |
| 208 | client: client, |
| 209 | io: ios, |
nothing calls this directly
no test coverage detected