Skip to content

Commit

Permalink
Increase number of unit tests for compareVersion function
Browse files Browse the repository at this point in the history
  • Loading branch information
koala7659 committed Nov 13, 2024
1 parent bfb22f3 commit b7acde8
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions pkg/gardener/shoot/extender/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ func TestCompareVersions(t *testing.T) {
version2: "2.0.0",
expected: -1,
},
{
name: "version1 is less than version2 with minor version",
version1: "1.0.0",
version2: "1.1.0",
expected: -1,
},
{
name: "version1 is less than version2 with patch version",
version1: "1.0.0",
version2: "1.0.1",
expected: -1,
},
{
name: "version1 is equal to version2",
version1: "1.0.0",
Expand All @@ -153,18 +165,66 @@ func TestCompareVersions(t *testing.T) {
version2: "1.0.0",
expected: 1,
},
{
name: "version1 is greater than version2 with minor version",
version1: "1.1.0",
version2: "1.0.0",
expected: 1,
},
{
name: "version1 is greater than version2 with patch version",
version1: "1.0.1",
version2: "1.0.0",
expected: 1,
},
{
name: "versions are in strange format 1",
version1: "10.6.2800-118",
version2: "10.6.2800-119",
expected: -1,
},
{
name: "versions are in strange format 2",
version1: "15.5.20240522+fips",
version2: "15.5.20240524+fips",
expected: -1,
},
{
name: "versions are in strange format 3",
version1: "10.6.2800-118",
version2: "10.6.2900-118",
expected: -1,
},
{
name: "versions are in strange format 4",
version1: "15.5.20240522+fips",
version2: "15.6.20240522+fips",
expected: -1,
},
{
name: "invalid version1",
version1: "invalid",
version2: "1.0.0",
expectErr: true,
},
{
name: "empty version1",
version1: "",
version2: "1.0.0",
expectErr: true,
},
{
name: "invalid version2",
version1: "1.0.0",
version2: "invalid",
expectErr: true,
},
{
name: "empty version2",
version1: "1.0.0",
version2: "",
expectErr: true,
},
}

for _, tt := range tests {
Expand Down

0 comments on commit b7acde8

Please sign in to comment.