Chore: update test coverage (#4730)

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>

Signed-off-by: Jianbo Sun <jianbo.sjb@alibaba-inc.com>
This commit is contained in:
Jianbo Sun 2022-09-15 13:55:16 +08:00 committed by GitHub
parent 682c76b8c0
commit 43131d88f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 0 deletions

View File

@ -9,3 +9,4 @@ coverage:
ignore: ignore:
- "**/zz_generated.deepcopy.go" - "**/zz_generated.deepcopy.go"
- "references/" - "references/"
- "apis/"

43
version/version_test.go Normal file
View File

@ -0,0 +1,43 @@
/*
Copyright 2022 The KubeVela Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package version
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestIsOfficialKubeVelaVersion(t *testing.T) {
assert.Equal(t, true, IsOfficialKubeVelaVersion("v1.2.3"))
assert.Equal(t, true, IsOfficialKubeVelaVersion("1.2.3"))
assert.Equal(t, true, IsOfficialKubeVelaVersion("v1.2"))
assert.Equal(t, true, IsOfficialKubeVelaVersion("v1.2+myvela"))
assert.Equal(t, false, IsOfficialKubeVelaVersion("v1.-"))
}
func TestGetVersion(t *testing.T) {
version, err := GetOfficialKubeVelaVersion("v1.2.90")
assert.Nil(t, err)
assert.Equal(t, "1.2.90", version)
version, err = GetOfficialKubeVelaVersion("1.2.90")
assert.Nil(t, err)
assert.Equal(t, "1.2.90", version)
version, err = GetOfficialKubeVelaVersion("v1.2+myvela")
assert.Nil(t, err)
assert.Equal(t, "1.2.0", version)
}