MCPcopy Create free account
hub / github.com/entireio/git-sync / TestParseMapping

Function TestParseMapping

internal/validation/validation_test.go:42–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func 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
76func TestValidateEndpoints(t *testing.T) {
77 t.Parallel()

Callers

nothing calls this directly

Calls 1

ParseMappingFunction · 0.85

Tested by

no test coverage detected