(t *testing.T)
| 5200 | } |
| 5201 | |
| 5202 | func TestCopilotService_ListCopilotSeatsIter(t *testing.T) { |
| 5203 | t.Parallel() |
| 5204 | client, mux, _ := setup(t) |
| 5205 | var callNum int |
| 5206 | mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { |
| 5207 | callNum++ |
| 5208 | switch callNum { |
| 5209 | case 1: |
| 5210 | w.Header().Set("Link", `<https://api.github.com/?page=1>; rel="next"`) |
| 5211 | fmt.Fprint(w, `{"seats": [{},{},{}]}`) |
| 5212 | case 2: |
| 5213 | fmt.Fprint(w, `{"seats": [{},{},{},{}]}`) |
| 5214 | case 3: |
| 5215 | fmt.Fprint(w, `{"seats": [{},{}]}`) |
| 5216 | case 4: |
| 5217 | w.WriteHeader(http.StatusNotFound) |
| 5218 | case 5: |
| 5219 | fmt.Fprint(w, `{"seats": [{},{}]}`) |
| 5220 | } |
| 5221 | }) |
| 5222 | |
| 5223 | iter := client.Copilot.ListCopilotSeatsIter(t.Context(), "", nil) |
| 5224 | var gotItems int |
| 5225 | for _, err := range iter { |
| 5226 | gotItems++ |
| 5227 | if err != nil { |
| 5228 | t.Errorf("Unexpected error: %v", err) |
| 5229 | } |
| 5230 | } |
| 5231 | if want := 7; gotItems != want { |
| 5232 | t.Errorf("client.Copilot.ListCopilotSeatsIter call 1 got %v items; want %v", gotItems, want) |
| 5233 | } |
| 5234 | |
| 5235 | opts := &ListOptions{} |
| 5236 | iter = client.Copilot.ListCopilotSeatsIter(t.Context(), "", opts) |
| 5237 | gotItems = 0 |
| 5238 | for _, err := range iter { |
| 5239 | gotItems++ |
| 5240 | if err != nil { |
| 5241 | t.Errorf("Unexpected error: %v", err) |
| 5242 | } |
| 5243 | } |
| 5244 | if want := 2; gotItems != want { |
| 5245 | t.Errorf("client.Copilot.ListCopilotSeatsIter call 2 got %v items; want %v", gotItems, want) |
| 5246 | } |
| 5247 | |
| 5248 | iter = client.Copilot.ListCopilotSeatsIter(t.Context(), "", nil) |
| 5249 | gotItems = 0 |
| 5250 | for _, err := range iter { |
| 5251 | gotItems++ |
| 5252 | if err == nil { |
| 5253 | t.Error("expected error; got nil") |
| 5254 | } |
| 5255 | } |
| 5256 | if gotItems != 1 { |
| 5257 | t.Errorf("client.Copilot.ListCopilotSeatsIter call 3 got %v items; want 1 (an error)", gotItems) |
| 5258 | } |
| 5259 |
nothing calls this directly
no test coverage detected
searching dependent graphs…