1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-26 05:14:13 +01:00

fix: minor version parsing in version compatibility check

Signed-off-by: Amir Alavi <amiralavi7@gmail.com>
This commit is contained in:
Amir Alavi
2024-06-07 00:03:39 -04:00
parent 55a0812ae6
commit a3146a1705
9 changed files with 840 additions and 23 deletions

View File

@@ -0,0 +1,54 @@
package version
import (
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
)
func TestGet(t *testing.T) {
tests := []struct {
name string
version string
want Info
}{
{
name: "parses automated container release tag",
version: "v20240519-v0.30.0",
want: Info{
Major: "0",
Minor: "30.0",
GitVersion: "v20240519-v0.30.0",
},
},
{
name: "parses automated container build",
version: "v20240520-v0.30.0-5-g79990946",
want: Info{
Major: "0",
Minor: "30.0",
GitVersion: "v20240520-v0.30.0-5-g79990946",
},
},
{
name: "parses helm release tag",
version: "v20240606-descheduler-helm-chart-0.30.0-18-g8714397b",
want: Info{
Major: "0",
Minor: "30.0",
GitVersion: "v20240606-descheduler-helm-chart-0.30.0-18-g8714397b",
},
},
}
ignoreRuntimeFields := cmpopts.IgnoreFields(Info{}, "GoVersion", "Compiler", "Platform")
for _, tt := range tests {
version = tt.version
t.Run(tt.name, func(t *testing.T) {
got := Get()
if diff := cmp.Diff(got, tt.want, ignoreRuntimeFields); diff != "" {
t.Errorf("Get (-want, +got):\n%s", diff)
}
})
}
}