(t *testing.T)
| 40 | } |
| 41 | |
| 42 | func TestParseMapping(t *testing.T) { |
| 43 | tests := []struct { |
| 44 | name string |
| 45 | input string |
| 46 | wantSrc string |
| 47 | wantDst string |
| 48 | wantErr bool |
| 49 | }{ |
| 50 | {name: "short refs", input: "main:stable", wantSrc: "main", wantDst: "stable"}, |
| 51 | {name: "trim whitespace", input: " refs/heads/main : refs/heads/stable ", wantSrc: "refs/heads/main", wantDst: "refs/heads/stable"}, |
| 52 | {name: "missing colon", input: "main", wantErr: true}, |
| 53 | {name: "empty source", input: ":stable", wantErr: true}, |
| 54 | {name: "empty target", input: "main:", wantErr: true}, |
| 55 | } |
| 56 | |
| 57 | for _, tt := range tests { |
| 58 | t.Run(tt.name, func(t *testing.T) { |
| 59 | got, err := ParseMapping(tt.input) |
| 60 | if tt.wantErr { |
| 61 | if err == nil { |
| 62 | t.Fatal("expected error") |
| 63 | } |
| 64 | return |
| 65 | } |
| 66 | if err != nil { |
| 67 | t.Fatalf("ParseMapping: %v", err) |
| 68 | } |
| 69 | if got.Source != tt.wantSrc || got.Target != tt.wantDst { |
| 70 | t.Fatalf("ParseMapping(%q) = %+v, want source=%q target=%q", tt.input, got, tt.wantSrc, tt.wantDst) |
| 71 | } |
| 72 | }) |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | func TestValidateEndpoints(t *testing.T) { |
| 77 | t.Parallel() |
nothing calls this directly
no test coverage detected