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

Function TestRepositoriesService_GetBranch_notFound

github/repos_test.go:1062–1102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1060}
1061
1062func 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
1104func TestRepositoriesService_RenameBranch(t *testing.T) {
1105 t.Parallel()

Callers

nothing calls this directly

Calls 7

testMethodFunction · 0.85
roundTripperFuncFuncType · 0.85
testBadOptionsFunction · 0.85
setupFunction · 0.70
RunMethod · 0.45
ErrorMethod · 0.45
GetBranchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…