From 43131d88f5ab3ff6eac630213d734c6529626bb2 Mon Sep 17 00:00:00 2001 From: Jianbo Sun Date: Thu, 15 Sep 2022 13:55:16 +0800 Subject: [PATCH] Chore: update test coverage (#4730) Signed-off-by: Jianbo Sun Signed-off-by: Jianbo Sun --- codecov.yml | 1 + version/version_test.go | 43 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 version/version_test.go diff --git a/codecov.yml b/codecov.yml index a6e69fb33..bb55584b1 100644 --- a/codecov.yml +++ b/codecov.yml @@ -9,3 +9,4 @@ coverage: ignore: - "**/zz_generated.deepcopy.go" - "references/" + - "apis/" diff --git a/version/version_test.go b/version/version_test.go new file mode 100644 index 000000000..10d5b2374 --- /dev/null +++ b/version/version_test.go @@ -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) +}