go-zero/tools/goctl/internal/env/env_test.go
anqiansong 189721da16
Fix issues (#931)
* fix #929

* fix #925

* add test case

* update model README

* fix #929

* fix #929

* fix #929

* refactor dir

* Adding todo comments

Co-authored-by: anqiansong <anqiansong@xiaoheiban.cn>
2021-08-19 22:47:45 +08:00

34 lines
864 B
Go

package env
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) {
assert.False(t, IsVersionGatherThan("0.11", "1.1"))
assert.True(t, IsVersionGatherThan("0.112", "0.1"))
assert.True(t, IsVersionGatherThan("1.1.10", "1.0.111"))
assert.True(t, IsVersionGatherThan("1.1.10", "1.1.10-pre"))
assert.True(t, IsVersionGatherThan("1.1.11-pre", "1.1.10"))
}