(t *testing.T)
| 5 | ) |
| 6 | |
| 7 | func TestRefspec(t *testing.T) { |
| 8 | t.Parallel() |
| 9 | |
| 10 | const ( |
| 11 | input = "+refs/heads/*:refs/remotes/origin/*" |
| 12 | mainLocal = "refs/heads/main" |
| 13 | mainRemote = "refs/remotes/origin/main" |
| 14 | ) |
| 15 | |
| 16 | refspec, err := ParseRefspec(input, true) |
| 17 | checkFatal(t, err) |
| 18 | |
| 19 | // Accessors |
| 20 | |
| 21 | s := refspec.String() |
| 22 | if s != input { |
| 23 | t.Errorf("expected string %q, got %q", input, s) |
| 24 | } |
| 25 | |
| 26 | if d := refspec.Direction(); d != ConnectDirectionFetch { |
| 27 | t.Errorf("expected fetch refspec, got direction %v", d) |
| 28 | } |
| 29 | |
| 30 | if pat, expected := refspec.Src(), "refs/heads/*"; pat != expected { |
| 31 | t.Errorf("expected refspec src %q, got %q", expected, pat) |
| 32 | } |
| 33 | |
| 34 | if pat, expected := refspec.Dst(), "refs/remotes/origin/*"; pat != expected { |
| 35 | t.Errorf("expected refspec dst %q, got %q", expected, pat) |
| 36 | } |
| 37 | |
| 38 | if !refspec.Force() { |
| 39 | t.Error("expected refspec force flag") |
| 40 | } |
| 41 | |
| 42 | // SrcMatches |
| 43 | |
| 44 | if !refspec.SrcMatches(mainLocal) { |
| 45 | t.Errorf("refspec source did not match %q", mainLocal) |
| 46 | } |
| 47 | |
| 48 | if refspec.SrcMatches("refs/tags/v1.0") { |
| 49 | t.Error("refspec source matched under refs/tags") |
| 50 | } |
| 51 | |
| 52 | // DstMatches |
| 53 | |
| 54 | if !refspec.DstMatches(mainRemote) { |
| 55 | t.Errorf("refspec destination did not match %q", mainRemote) |
| 56 | } |
| 57 | |
| 58 | if refspec.DstMatches("refs/tags/v1.0") { |
| 59 | t.Error("refspec destination matched under refs/tags") |
| 60 | } |
| 61 | |
| 62 | // Transforms |
| 63 | |
| 64 | fromLocal, err := refspec.Transform(mainLocal) |
nothing calls this directly
no test coverage detected
searching dependent graphs…