-
Notifications
You must be signed in to change notification settings - Fork 0
/
e2e_test.go
74 lines (57 loc) · 1.69 KB
/
e2e_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"testing"
tassert "github.com/stretchr/testify/assert"
)
func TestParseVersionString(t *testing.T) {
assert := tassert.New(t)
validStr := "1.2.3"
expVersion := Version{Major: 1, Minor: 2, Patch: 3}
v, err := ParseVerionString(validStr)
assert.NoError(err)
assert.Equal(expVersion, v)
invalidStr := "a.b.c"
_, err = ParseVerionString(invalidStr)
assert.Error(err)
}
func TestValidateMetaData(t *testing.T) {
assert := tassert.New(t)
assert.True(validateMetaData("alpha.123"))
assert.True(validateMetaData("aoms-dsoj.9283429.shfj"))
assert.False(validateMetaData("hsghgdf."))
assert.False(validateMetaData("&sdjshb"))
assert.False(validateMetaData("&#$%^&*"))
}
func TestParseIncrementLevel(t *testing.T) {
assert := tassert.New(t)
r, err := ParseIncrementLevel("major")
assert.NoError(err)
assert.Equal(Major, r)
r, err = ParseIncrementLevel("minor")
assert.NoError(err)
assert.Equal(Minor, r)
r, err = ParseIncrementLevel("patch")
assert.NoError(err)
assert.Equal(Patch, r)
r, err = ParseIncrementLevel("premajor")
assert.NoError(err)
assert.Equal(PreMajor, r)
r, err = ParseIncrementLevel("preminor")
assert.NoError(err)
assert.Equal(PreMinor, r)
r, err = ParseIncrementLevel("prepatch")
assert.NoError(err)
assert.Equal(PrePatch, r)
_, err = ParseIncrementLevel("something")
assert.Error(err)
}
func TestParseFlags(t *testing.T) {
assert := tassert.New(t)
contr, err := ParseFlags("invalid", "alpha", "rng", "metadata")
assert.Error(err)
contr, err = ParseFlags("major", "alpha", "range", "meta")
assert.NoError(err)
assert.Equal("meta", contr.BuildMeta)
assert.Equal(Major, contr.IncrementLevel)
assert.Equal("alpha", contr.PreIdentifier)
}