MCPcopy Create free account
hub / github.com/libgit2/git2go / TestRefspec

Function TestRefspec

refspec_test.go:7–75  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5)
6
7func 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)

Callers

nothing calls this directly

Calls 12

ParseRefspecFunction · 0.85
checkFatalFunction · 0.85
DirectionMethod · 0.80
SrcMethod · 0.80
DstMethod · 0.80
ForceMethod · 0.80
ErrorMethod · 0.80
SrcMatchesMethod · 0.80
DstMatchesMethod · 0.80
TransformMethod · 0.80
RtransformMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…