MCPcopy Index your code
hub / github.com/google/go-github / TestIssuesService_ListLabelsIter

Function TestIssuesService_ListLabelsIter

github/github-iterators_test.go:7866–7936  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7864}
7865
7866func TestIssuesService_ListLabelsIter(t *testing.T) {
7867 t.Parallel()
7868 client, mux, _ := setup(t)
7869 var callNum int
7870 mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
7871 callNum++
7872 switch callNum {
7873 case 1:
7874 w.Header().Set("Link", `<https://api.github.com/?page=1>; rel="next"`)
7875 fmt.Fprint(w, `[{},{},{}]`)
7876 case 2:
7877 fmt.Fprint(w, `[{},{},{},{}]`)
7878 case 3:
7879 fmt.Fprint(w, `[{},{}]`)
7880 case 4:
7881 w.WriteHeader(http.StatusNotFound)
7882 case 5:
7883 fmt.Fprint(w, `[{},{}]`)
7884 }
7885 })
7886
7887 iter := client.Issues.ListLabelsIter(t.Context(), "", "", nil)
7888 var gotItems int
7889 for _, err := range iter {
7890 gotItems++
7891 if err != nil {
7892 t.Errorf("Unexpected error: %v", err)
7893 }
7894 }
7895 if want := 7; gotItems != want {
7896 t.Errorf("client.Issues.ListLabelsIter call 1 got %v items; want %v", gotItems, want)
7897 }
7898
7899 opts := &ListOptions{}
7900 iter = client.Issues.ListLabelsIter(t.Context(), "", "", opts)
7901 gotItems = 0
7902 for _, err := range iter {
7903 gotItems++
7904 if err != nil {
7905 t.Errorf("Unexpected error: %v", err)
7906 }
7907 }
7908 if want := 2; gotItems != want {
7909 t.Errorf("client.Issues.ListLabelsIter call 2 got %v items; want %v", gotItems, want)
7910 }
7911
7912 iter = client.Issues.ListLabelsIter(t.Context(), "", "", nil)
7913 gotItems = 0
7914 for _, err := range iter {
7915 gotItems++
7916 if err == nil {
7917 t.Error("expected error; got nil")
7918 }
7919 }
7920 if gotItems != 1 {
7921 t.Errorf("client.Issues.ListLabelsIter call 3 got %v items; want 1 (an error)", gotItems)
7922 }
7923

Callers

nothing calls this directly

Calls 3

ListLabelsIterMethod · 0.80
setupFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…