github.com/wiselike/revel-cmd@v1.2.1/model/version_test.go (about) 1 package model_test 2 3 import ( 4 "testing" 5 6 "github.com/wiselike/revel-cmd/model" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 var versionTests = [][]string{ 11 {"v0.20.0-dev", "v0.20.0-dev"}, 12 {"v0.20-dev", "v0.20.0-dev"}, 13 {"v0.20.", "v0.20.0"}, 14 {"2.0", "2.0.0"}, 15 } 16 17 // Test that the event handler can be attached and it dispatches the event received. 18 func TestVersion(t *testing.T) { 19 for _, v := range versionTests { 20 p, e := model.ParseVersion(v[0]) 21 assert.Nil(t, e, "Should have parsed %s", v) 22 assert.Equal(t, p.String(), v[1], "Should be equal %s==%s", p.String(), v) 23 } 24 } 25 26 // test the ranges. 27 func TestVersionRange(t *testing.T) { 28 a, _ := model.ParseVersion("0.1.2") 29 b, _ := model.ParseVersion("0.2.1") 30 c, _ := model.ParseVersion("1.0.1") 31 assert.True(t, b.MinorNewer(a), "B is newer then A") 32 assert.False(t, b.MajorNewer(a), "B is not major newer then A") 33 assert.False(t, b.MajorNewer(c), "B is not major newer then A") 34 assert.True(t, c.MajorNewer(b), "C is major newer then b") 35 }