(t *testing.T)
| 110 | } |
| 111 | |
| 112 | func TestLicensesService_List(t *testing.T) { |
| 113 | t.Parallel() |
| 114 | client, mux, _ := setup(t) |
| 115 | |
| 116 | mux.HandleFunc("/licenses", func(w http.ResponseWriter, r *http.Request) { |
| 117 | testMethod(t, r, "GET") |
| 118 | testFormValues(t, r, values{"featured": "true", "page": "2", "per_page": "20"}) |
| 119 | fmt.Fprint(w, `[{"key":"mit","name":"MIT","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","featured":true}]`) |
| 120 | }) |
| 121 | |
| 122 | opts := &ListLicensesOptions{Featured: Ptr(true), ListOptions: ListOptions{Page: 2, PerPage: 20}} |
| 123 | ctx := t.Context() |
| 124 | licenses, _, err := client.Licenses.List(ctx, opts) |
| 125 | if err != nil { |
| 126 | t.Errorf("Licenses.List returned error: %v", err) |
| 127 | } |
| 128 | |
| 129 | want := []*License{{ |
| 130 | Key: Ptr("mit"), |
| 131 | Name: Ptr("MIT"), |
| 132 | SPDXID: Ptr("MIT"), |
| 133 | URL: Ptr("https://api.github.com/licenses/mit"), |
| 134 | Featured: Ptr(true), |
| 135 | }} |
| 136 | if !cmp.Equal(licenses, want) { |
| 137 | t.Errorf("Licenses.List returned %+v, want %+v", licenses, want) |
| 138 | } |
| 139 | |
| 140 | const methodName = "List" |
| 141 | testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 142 | got, resp, err := client.Licenses.List(ctx, opts) |
| 143 | if got != nil { |
| 144 | t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 145 | } |
| 146 | return resp, err |
| 147 | }) |
| 148 | } |
| 149 | |
| 150 | func TestLicensesService_Get(t *testing.T) { |
| 151 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…