You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
873 B
Go
34 lines
873 B
Go
3 years ago
|
package version
|
||
3 years ago
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func Test_convertVersion(t *testing.T) {
|
||
|
number, tag := convertVersion("1.1.10")
|
||
|
assert.Equal(t, 1.110, number)
|
||
|
assert.Equal(t, "", tag)
|
||
|
|
||
|
number, tag = convertVersion("0.1.11")
|
||
|
assert.Equal(t, 0.111, number)
|
||
|
assert.Equal(t, "", tag)
|
||
|
|
||
|
number, tag = convertVersion("1.11-pre")
|
||
|
assert.Equal(t, 1.11, number)
|
||
|
assert.Equal(t, "pre", tag)
|
||
|
|
||
|
number, tag = convertVersion("1.11-beta-v1")
|
||
|
assert.Equal(t, 1.11, number)
|
||
|
assert.Equal(t, "betav1", tag)
|
||
|
}
|
||
|
|
||
|
func Test_IsVersionGatherThan(t *testing.T) {
|
||
3 years ago
|
assert.False(t, IsVersionGreaterThan("0.11", "1.1"))
|
||
|
assert.True(t, IsVersionGreaterThan("0.112", "0.1"))
|
||
|
assert.True(t, IsVersionGreaterThan("1.1.10", "1.0.111"))
|
||
|
assert.True(t, IsVersionGreaterThan("1.1.10", "1.1.10-pre"))
|
||
|
assert.True(t, IsVersionGreaterThan("1.1.11-pre", "1.1.10"))
|
||
3 years ago
|
}
|