(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func Test_ListPullRequests(t *testing.T) { |
| 16 | type args struct { |
| 17 | detector fd.Detector |
| 18 | repo ghrepo.Interface |
| 19 | filters prShared.FilterOptions |
| 20 | limit int |
| 21 | } |
| 22 | tests := []struct { |
| 23 | name string |
| 24 | args args |
| 25 | httpStub func(*testing.T, *httpmock.Registry) |
| 26 | wantErr bool |
| 27 | }{ |
| 28 | { |
| 29 | name: "default", |
| 30 | args: args{ |
| 31 | repo: ghrepo.New("OWNER", "REPO"), |
| 32 | limit: 30, |
| 33 | filters: prShared.FilterOptions{ |
| 34 | State: "open", |
| 35 | }, |
| 36 | }, |
| 37 | httpStub: func(t *testing.T, r *httpmock.Registry) { |
| 38 | r.Register( |
| 39 | httpmock.GraphQL(`query PullRequestList\b`), |
| 40 | httpmock.GraphQLQuery(`{"data":{}}`, func(query string, vars map[string]interface{}) { |
| 41 | want := map[string]interface{}{ |
| 42 | "owner": "OWNER", |
| 43 | "repo": "REPO", |
| 44 | "state": []interface{}{"OPEN"}, |
| 45 | "limit": float64(30), |
| 46 | } |
| 47 | if !reflect.DeepEqual(vars, want) { |
| 48 | t.Errorf("got GraphQL variables %#v, want %#v", vars, want) |
| 49 | } |
| 50 | })) |
| 51 | }, |
| 52 | }, |
| 53 | { |
| 54 | name: "closed", |
| 55 | args: args{ |
| 56 | repo: ghrepo.New("OWNER", "REPO"), |
| 57 | limit: 30, |
| 58 | filters: prShared.FilterOptions{ |
| 59 | State: "closed", |
| 60 | }, |
| 61 | }, |
| 62 | httpStub: func(t *testing.T, r *httpmock.Registry) { |
| 63 | r.Register( |
| 64 | httpmock.GraphQL(`query PullRequestList\b`), |
| 65 | httpmock.GraphQLQuery(`{"data":{}}`, func(query string, vars map[string]interface{}) { |
| 66 | want := map[string]interface{}{ |
| 67 | "owner": "OWNER", |
| 68 | "repo": "REPO", |
| 69 | "state": []interface{}{"CLOSED", "MERGED"}, |
| 70 | "limit": float64(30), |
| 71 | } |
| 72 | if !reflect.DeepEqual(vars, want) { |
nothing calls this directly
no test coverage detected