@@ -3242,6 +3242,45 @@ func TestRepositoriesService_GetSignaturesProtectedBranch(t *testing.T) {
32423242 }
32433243}
32443244
3245+ func TestRepositoriesService_GetSignaturesProtectedBranch_branchNotProtected (t * testing.T ) {
3246+ t .Parallel ()
3247+ tests := []struct {
3248+ branch string
3249+ urlPath string
3250+ }{
3251+ {branch : "b" , urlPath : "/repos/o/r/branches/b/protection/required_signatures" },
3252+ {branch : "feat/branch-50%" , urlPath : "/repos/o/r/branches/feat%2fbranch-50%25/protection/required_signatures" },
3253+ }
3254+
3255+ for _ , test := range tests {
3256+ t .Run (test .branch , func (t * testing.T ) {
3257+ t .Parallel ()
3258+ client , mux , _ := setup (t )
3259+
3260+ mux .HandleFunc (test .urlPath , func (w http.ResponseWriter , r * http.Request ) {
3261+ testMethod (t , r , "GET" )
3262+
3263+ w .WriteHeader (http .StatusBadRequest )
3264+ fmt .Fprintf (w , `{
3265+ "message": %q,
3266+ "documentation_url": "https://docs.github.com/rest/repos#get-branch-protection"
3267+ }` , githubBranchNotProtected )
3268+ })
3269+
3270+ ctx := t .Context ()
3271+ checks , _ , err := client .Repositories .GetSignaturesProtectedBranch (ctx , "o" , "r" , test .branch )
3272+
3273+ if checks != nil {
3274+ t .Error ("Repositories.GetSignaturesProtectedBranch returned non-nil status-checks data" )
3275+ }
3276+
3277+ if ! errors .Is (err , ErrBranchNotProtected ) {
3278+ t .Errorf ("Repositories.GetSignaturesProtectedBranch returned an invalid error: %v" , err )
3279+ }
3280+ })
3281+ }
3282+ }
3283+
32453284func TestRepositoriesService_RequireSignaturesOnProtectedBranch (t * testing.T ) {
32463285 t .Parallel ()
32473286 tests := []struct {
0 commit comments