(t *testing.T)
| 909 | } |
| 910 | |
| 911 | func Test_SearchIssues_IFC_InsidersMode(t *testing.T) { |
| 912 | t.Parallel() |
| 913 | |
| 914 | serverTool := SearchIssues(translations.NullTranslationHelper) |
| 915 | |
| 916 | makeIssue := func(owner, repo string, number int) *github.Issue { |
| 917 | return &github.Issue{ |
| 918 | Number: github.Ptr(number), |
| 919 | Title: github.Ptr("issue"), |
| 920 | State: github.Ptr("open"), |
| 921 | RepositoryURL: github.Ptr("https://api.github.com/repos/" + owner + "/" + repo), |
| 922 | User: &github.User{Login: github.Ptr("u")}, |
| 923 | } |
| 924 | } |
| 925 | |
| 926 | type repoFixture struct { |
| 927 | owner string |
| 928 | repo string |
| 929 | isPrivate bool |
| 930 | repoStatus int |
| 931 | } |
| 932 | |
| 933 | repoHandlers := func(repos []repoFixture) map[string]http.HandlerFunc { |
| 934 | repoByPath := map[string]repoFixture{} |
| 935 | for _, r := range repos { |
| 936 | repoByPath["/repos/"+r.owner+"/"+r.repo] = r |
| 937 | } |
| 938 | return map[string]http.HandlerFunc{ |
| 939 | GetReposByOwnerByRepo: func(w http.ResponseWriter, req *http.Request) { |
| 940 | r, ok := repoByPath[req.URL.Path] |
| 941 | if !ok { |
| 942 | w.WriteHeader(http.StatusNotFound) |
| 943 | return |
| 944 | } |
| 945 | if r.repoStatus != 0 && r.repoStatus != http.StatusOK { |
| 946 | w.WriteHeader(r.repoStatus) |
| 947 | return |
| 948 | } |
| 949 | body, _ := json.Marshal(map[string]any{ |
| 950 | "name": r.repo, |
| 951 | "private": r.isPrivate, |
| 952 | }) |
| 953 | w.WriteHeader(http.StatusOK) |
| 954 | _, _ = w.Write(body) |
| 955 | }, |
| 956 | } |
| 957 | } |
| 958 | |
| 959 | makeMockClient := func(searchResult *github.IssuesSearchResult, repos []repoFixture) *http.Client { |
| 960 | handlers := repoHandlers(repos) |
| 961 | handlers[GetSearchIssues] = mockResponse(t, http.StatusOK, searchResult) |
| 962 | return MockHTTPClientWithHandlers(handlers) |
| 963 | } |
| 964 | |
| 965 | reqParams := map[string]any{"query": "bug"} |
| 966 | |
| 967 | t.Run("insiders mode disabled omits ifc label", func(t *testing.T) { |
| 968 | searchResult := &github.IssuesSearchResult{Issues: []*github.Issue{makeIssue("octocat", "public-repo", 1)}} |
nothing calls this directly
no test coverage detected