(t *testing.T)
| 116 | } |
| 117 | |
| 118 | func TestNormalizeMappingAllowOther(t *testing.T) { |
| 119 | tests := []struct { |
| 120 | name string |
| 121 | mapping RefMapping |
| 122 | allowOther bool |
| 123 | wantErr bool |
| 124 | }{ |
| 125 | {name: "notes ref blocked by default", mapping: RefMapping{Source: "refs/notes/commits", Target: "refs/notes/commits"}, wantErr: true}, |
| 126 | {name: "notes ref allowed with allowOther", mapping: RefMapping{Source: "refs/notes/commits", Target: "refs/notes/commits"}, allowOther: true}, |
| 127 | {name: "pull ref allowed with allowOther", mapping: RefMapping{Source: "refs/pull/1/head", Target: "refs/pull/1/head"}, allowOther: true}, |
| 128 | {name: "cross-kind still blocked with allowOther", mapping: RefMapping{Source: "refs/heads/main", Target: "refs/notes/commits"}, allowOther: true, wantErr: true}, |
| 129 | {name: "branch unchanged when allowOther", mapping: RefMapping{Source: "refs/heads/main", Target: "refs/heads/main"}, allowOther: true}, |
| 130 | } |
| 131 | |
| 132 | for _, tt := range tests { |
| 133 | t.Run(tt.name, func(t *testing.T) { |
| 134 | _, err := NormalizeMapping(tt.mapping, tt.allowOther) |
| 135 | if tt.wantErr { |
| 136 | if err == nil { |
| 137 | t.Fatalf("NormalizeMapping(%+v, %v) = nil, want error", tt.mapping, tt.allowOther) |
| 138 | } |
| 139 | return |
| 140 | } |
| 141 | if err != nil { |
| 142 | t.Fatalf("NormalizeMapping(%+v, %v) = %v, want nil", tt.mapping, tt.allowOther, err) |
| 143 | } |
| 144 | }) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | func TestParseHaveRef(t *testing.T) { |
| 149 | tests := []struct { |
nothing calls this directly
no test coverage detected