-
Notifications
You must be signed in to change notification settings - Fork 0
/
version_test.go
50 lines (42 loc) · 893 Bytes
/
version_test.go
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
package semvergo
import (
"fmt"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestFromString(t *testing.T) {
Convey("When calling FromString", t, func() {
tests := map[string]struct {
input string
output *Version
err error
}{
"simple passing": {
input: "0.0.1",
output: &Version{0, 0, 1, "", ""},
err: nil,
},
"alpha branch": {
input: "0.0.1-alpha",
output: &Version{0, 0, 1, "alpha", ""},
err: nil,
},
}
for k, v := range tests {
s := "<nil>"
if v.output != nil {
s = v.output.String()
}
Convey(fmt.Sprintf("Given case: %s - %s", k, s), func() {
ver, err := fromString(v.input)
So(err, ShouldEqual, v.err)
if v.output != nil {
So(ver, ShouldNotBeNil)
So(ver.String(), ShouldEqual, v.output.String())
} else {
So(ver, ShouldBeNil)
}
})
}
})
}