@@ -40,41 +40,43 @@ func TestIsStdLib(t *testing.T) {
40
40
41
41
func TestGetProjectPropertiesFromVersion (t * testing.T ) {
42
42
cases := []struct {
43
- version gps.Version
44
- expected gps.Version
43
+ version gps.Version
44
+ want gps.Version
45
45
}{
46
46
{
47
- version : gps .NewBranch ("foo-branch" ). Is ( "some-revision " ),
48
- expected : gps .NewBranch ("foo-branch" ),
47
+ version : gps .NewBranch ("foo-branch" ),
48
+ want : gps .NewBranch ("foo-branch" ),
49
49
},
50
50
{
51
- version : gps .NewVersion ("foo-version" ). Is ( "some-revision " ),
52
- expected : gps .NewVersion ("foo-version" ),
51
+ version : gps .NewVersion ("foo-version" ),
52
+ want : gps .NewVersion ("foo-version" ),
53
53
},
54
54
{
55
- version : gps .Revision ("alsjd934" ),
56
- expected : nil ,
55
+ version : gps .NewBranch ("foo-branch" ).Is ("some-revision" ),
56
+ want : gps .NewBranch ("foo-branch" ),
57
+ },
58
+ {
59
+ version : gps .NewVersion ("foo-version" ).Is ("some-revision" ),
60
+ want : gps .NewVersion ("foo-version" ),
61
+ },
62
+ {
63
+ version : gps .Revision ("some-revision" ),
64
+ want : nil ,
57
65
},
58
- // This fails. Hence, testing separately below.
59
- // {
60
- // version: gps.NewVersion("v1.0.0"),
61
- // expected: gps.NewVersion("^1.0.0"),
62
- // },
63
66
}
64
67
65
68
for _ , c := range cases {
66
69
actualProp := getProjectPropertiesFromVersion (c .version )
67
- if c .expected != actualProp .Constraint {
68
- t .Fatalf ("Expected %q to be equal to %q " , actualProp .Constraint , c .expected )
70
+ if c .want != actualProp .Constraint {
71
+ t .Fatalf ("Expected project property to be %v, got %v " , actualProp .Constraint , c .want )
69
72
}
70
73
}
71
74
75
+ // Test to have caret in semver version
72
76
outsemver := getProjectPropertiesFromVersion (gps .NewVersion ("v1.0.0" ))
73
- expectedSemver , _ := gps .NewSemverConstraint ("^1.0.0" )
74
- // Comparing outsemver.Constraint and expectedSemver fails with error
75
- // "comparing uncomparable type semver.rangeConstraint", although they have
76
- // same value and same type "gps.semverConstraint" as per "reflect".
77
- if outsemver .Constraint .String () != expectedSemver .String () {
78
- t .Fatalf ("Expected %q to be equal to %q" , outsemver , expectedSemver )
77
+ wantSemver , _ := gps .NewSemverConstraint ("^1.0.0" )
78
+
79
+ if outsemver .Constraint .String () != wantSemver .String () {
80
+ t .Fatalf ("Expected semver to be %v, got %v" , outsemver .Constraint , wantSemver )
79
81
}
80
82
}
0 commit comments