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

Function TestIssuesService_ListIssueEventsIter

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

Source from the content-addressed store, hash-verified

7720}
7721
7722func TestIssuesService_ListIssueEventsIter(t *testing.T) {
7723 t.Parallel()
7724 client, mux, _ := setup(t)
7725 var callNum int
7726 mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
7727 callNum++
7728 switch callNum {
7729 case 1:
7730 w.Header().Set("Link", `<https://api.github.com/?page=1>; rel="next"`)
7731 fmt.Fprint(w, `[{},{},{}]`)
7732 case 2:
7733 fmt.Fprint(w, `[{},{},{},{}]`)
7734 case 3:
7735 fmt.Fprint(w, `[{},{}]`)
7736 case 4:
7737 w.WriteHeader(http.StatusNotFound)
7738 case 5:
7739 fmt.Fprint(w, `[{},{}]`)
7740 }
7741 })
7742
7743 iter := client.Issues.ListIssueEventsIter(t.Context(), "", "", 0, nil)
7744 var gotItems int
7745 for _, err := range iter {
7746 gotItems++
7747 if err != nil {
7748 t.Errorf("Unexpected error: %v", err)
7749 }
7750 }
7751 if want := 7; gotItems != want {
7752 t.Errorf("client.Issues.ListIssueEventsIter call 1 got %v items; want %v", gotItems, want)
7753 }
7754
7755 opts := &ListOptions{}
7756 iter = client.Issues.ListIssueEventsIter(t.Context(), "", "", 0, opts)
7757 gotItems = 0
7758 for _, err := range iter {
7759 gotItems++
7760 if err != nil {
7761 t.Errorf("Unexpected error: %v", err)
7762 }
7763 }
7764 if want := 2; gotItems != want {
7765 t.Errorf("client.Issues.ListIssueEventsIter call 2 got %v items; want %v", gotItems, want)
7766 }
7767
7768 iter = client.Issues.ListIssueEventsIter(t.Context(), "", "", 0, nil)
7769 gotItems = 0
7770 for _, err := range iter {
7771 gotItems++
7772 if err == nil {
7773 t.Error("expected error; got nil")
7774 }
7775 }
7776 if gotItems != 1 {
7777 t.Errorf("client.Issues.ListIssueEventsIter call 3 got %v items; want 1 (an error)", gotItems)
7778 }
7779

Callers

nothing calls this directly

Calls 3

ListIssueEventsIterMethod · 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…