(t *testing.T)
| 1060 | } |
| 1061 | |
| 1062 | func TestRepositoriesService_GetBranch_notFound(t *testing.T) { |
| 1063 | t.Parallel() |
| 1064 | tests := []struct { |
| 1065 | branch string |
| 1066 | urlPath string |
| 1067 | }{ |
| 1068 | {branch: "b", urlPath: "/repos/o/r/branches/b"}, |
| 1069 | {branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat-branch-50%"}, |
| 1070 | } |
| 1071 | |
| 1072 | for _, test := range tests { |
| 1073 | t.Run(test.branch, func(t *testing.T) { |
| 1074 | t.Parallel() |
| 1075 | client, mux, _ := setup(t) |
| 1076 | |
| 1077 | mux.HandleFunc(test.urlPath, func(w http.ResponseWriter, r *http.Request) { |
| 1078 | testMethod(t, r, "GET") |
| 1079 | http.Error(w, "branch not found", http.StatusNotFound) |
| 1080 | }) |
| 1081 | ctx := t.Context() |
| 1082 | _, resp, err := client.Repositories.GetBranch(ctx, "o", "r", test.branch, 1) |
| 1083 | if err == nil { |
| 1084 | t.Error("Repositories.GetBranch returned error: nil") |
| 1085 | } |
| 1086 | if resp.StatusCode != http.StatusNotFound { |
| 1087 | t.Errorf("Repositories.GetBranch returned status: %v, want %v", resp.StatusCode, http.StatusNotFound) |
| 1088 | } |
| 1089 | |
| 1090 | // Add custom round tripper |
| 1091 | client.client.Transport = roundTripperFunc(func(*http.Request) (*http.Response, error) { |
| 1092 | return nil, errors.New("failed to get branch") |
| 1093 | }) |
| 1094 | |
| 1095 | const methodName = "GetBranch" |
| 1096 | testBadOptions(t, methodName, func() (err error) { |
| 1097 | _, _, err = client.Repositories.GetBranch(ctx, "\n", "\n", "\n", 1) |
| 1098 | return err |
| 1099 | }) |
| 1100 | }) |
| 1101 | } |
| 1102 | } |
| 1103 | |
| 1104 | func TestRepositoriesService_RenameBranch(t *testing.T) { |
| 1105 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…