(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func Test_repoCreate(t *testing.T) { |
| 13 | tests := []struct { |
| 14 | name string |
| 15 | hostname string |
| 16 | input repoCreateInput |
| 17 | stubs func(t *testing.T, r *httpmock.Registry) |
| 18 | wantErr bool |
| 19 | errMsg string |
| 20 | wantRepo string |
| 21 | }{ |
| 22 | { |
| 23 | name: "create personal repository", |
| 24 | hostname: "github.com", |
| 25 | input: repoCreateInput{ |
| 26 | Name: "winter-foods", |
| 27 | Description: "roasted chestnuts", |
| 28 | HomepageURL: "http://example.com", |
| 29 | Visibility: "public", |
| 30 | HasIssuesEnabled: true, |
| 31 | HasWikiEnabled: true, |
| 32 | }, |
| 33 | stubs: func(t *testing.T, r *httpmock.Registry) { |
| 34 | r.Register( |
| 35 | httpmock.GraphQL(`mutation RepositoryCreate\b`), |
| 36 | httpmock.GraphQLMutation( |
| 37 | `{ |
| 38 | "data": { |
| 39 | "createRepository": { |
| 40 | "repository": { |
| 41 | "id": "REPOID", |
| 42 | "name": "REPO", |
| 43 | "owner": {"login":"OWNER"}, |
| 44 | "url": "the://URL" |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | }`, |
| 49 | func(inputs map[string]interface{}) { |
| 50 | assert.Equal(t, map[string]interface{}{ |
| 51 | "name": "winter-foods", |
| 52 | "description": "roasted chestnuts", |
| 53 | "homepageUrl": "http://example.com", |
| 54 | "visibility": "PUBLIC", |
| 55 | "hasIssuesEnabled": true, |
| 56 | "hasWikiEnabled": true, |
| 57 | }, inputs) |
| 58 | }), |
| 59 | ) |
| 60 | }, |
| 61 | wantRepo: "https://github.com/OWNER/REPO", |
| 62 | }, |
| 63 | { |
| 64 | name: "create Enterprise repository", |
| 65 | hostname: "example.com", |
| 66 | input: repoCreateInput{ |
| 67 | Name: "winter-foods", |
| 68 | Description: "roasted chestnuts", |
| 69 | HomepageURL: "http://example.com", |
nothing calls this directly
no test coverage detected