1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
package config
import (
"testing"
. "gopkg.in/check.v1"
"gopkg.in/src-d/go-git.v4/core"
)
type RefSpecSuite struct{}
var _ = Suite(&RefSpecSuite{})
func Test(t *testing.T) { TestingT(t) }
func (s *RefSpecSuite) TestRefSpecIsValid(c *C) {
spec := RefSpec("+refs/heads/*:refs/remotes/origin/*")
c.Assert(spec.IsValid(), Equals, true)
spec = RefSpec("refs/heads/*:refs/remotes/origin/")
c.Assert(spec.IsValid(), Equals, false)
spec = RefSpec("refs/heads/master:refs/remotes/origin/master")
c.Assert(spec.IsValid(), Equals, true)
spec = RefSpec("refs/heads/*")
c.Assert(spec.IsValid(), Equals, false)
}
func (s *RefSpecSuite) TestRefSpecIsForceUpdate(c *C) {
spec := RefSpec("+refs/heads/*:refs/remotes/origin/*")
c.Assert(spec.IsForceUpdate(), Equals, true)
spec = RefSpec("refs/heads/*:refs/remotes/origin/*")
c.Assert(spec.IsForceUpdate(), Equals, false)
}
func (s *RefSpecSuite) TestRefSpecSrc(c *C) {
spec := RefSpec("refs/heads/*:refs/remotes/origin/*")
c.Assert(spec.Src(), Equals, "refs/heads/*")
}
func (s *RefSpecSuite) TestRefSpecMatch(c *C) {
spec := RefSpec("refs/heads/master:refs/remotes/origin/master")
c.Assert(spec.Match(core.ReferenceName("refs/heads/foo")), Equals, false)
c.Assert(spec.Match(core.ReferenceName("refs/heads/master")), Equals, true)
}
func (s *RefSpecSuite) TestRefSpecMatchBlob(c *C) {
spec := RefSpec("refs/heads/*:refs/remotes/origin/*")
c.Assert(spec.Match(core.ReferenceName("refs/tag/foo")), Equals, false)
c.Assert(spec.Match(core.ReferenceName("refs/heads/foo")), Equals, true)
}
func (s *RefSpecSuite) TestRefSpecDst(c *C) {
spec := RefSpec("refs/heads/master:refs/remotes/origin/master")
c.Assert(
spec.Dst(core.ReferenceName("refs/heads/master")).String(), Equals,
"refs/remotes/origin/master",
)
}
func (s *RefSpecSuite) TestRefSpecDstBlob(c *C) {
spec := RefSpec("refs/heads/*:refs/remotes/origin/*")
c.Assert(
spec.Dst(core.ReferenceName("refs/heads/foo")).String(), Equals,
"refs/remotes/origin/foo",
)
}
|