(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestNormalizeProtocolMode(t *testing.T) { |
| 10 | tests := []struct { |
| 11 | name string |
| 12 | input string |
| 13 | want string |
| 14 | wantErr bool |
| 15 | }{ |
| 16 | {name: "default", input: "", want: ProtocolAuto}, |
| 17 | {name: "auto", input: ProtocolAuto, want: ProtocolAuto}, |
| 18 | {name: "v1", input: ProtocolV1, want: ProtocolV1}, |
| 19 | {name: "v2", input: ProtocolV2, want: ProtocolV2}, |
| 20 | {name: "invalid", input: "v3", wantErr: true}, |
| 21 | } |
| 22 | |
| 23 | for _, tt := range tests { |
| 24 | t.Run(tt.name, func(t *testing.T) { |
| 25 | got, err := NormalizeProtocolMode(tt.input) |
| 26 | if tt.wantErr { |
| 27 | if err == nil { |
| 28 | t.Fatal("expected error") |
| 29 | } |
| 30 | return |
| 31 | } |
| 32 | if err != nil { |
| 33 | t.Fatalf("NormalizeProtocolMode: %v", err) |
| 34 | } |
| 35 | if got != tt.want { |
| 36 | t.Fatalf("NormalizeProtocolMode(%q) = %q, want %q", tt.input, got, tt.want) |
| 37 | } |
| 38 | }) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | func TestParseMapping(t *testing.T) { |
| 43 | tests := []struct { |
nothing calls this directly
no test coverage detected