diff --git a/pkg/katatestutils/constraints_api.go b/pkg/katatestutils/constraints_api.go index 2c37d7d600..ce4af56f2e 100644 --- a/pkg/katatestutils/constraints_api.go +++ b/pkg/katatestutils/constraints_api.go @@ -190,6 +190,22 @@ func NeedDistroVersionEquals(version string) Constraint { return NeedDistroVersionWithOp(version, eqOperator) } +// NeedDistroVersionNotEquals will skip the test unless the distro version is +// different to the specified version. +// +// Note: distro versions vary in format. +func NeedDistroVersionNotEquals(version string) Constraint { + return NeedDistroVersionWithOp(version, neOperator) +} + +// NeedDistroVersionLE will skip the test unless the distro version is older +// than or the same as the specified version. +// +// Note: distro versions vary in format. +func NeedDistroVersionLE(version string) Constraint { + return NeedDistroVersionWithOp(version, leOperator) +} + // NeedDistroVersionLT will skip the test unless the distro version is older // than the specified version. // @@ -198,6 +214,14 @@ func NeedDistroVersionLT(version string) Constraint { return NeedDistroVersionWithOp(version, ltOperator) } +// NeedDistroVersionGE will skip the test unless the distro version is newer +// than or the same as the specified version. +// +// Note: distro versions vary in format. +func NeedDistroVersionGE(version string) Constraint { + return NeedDistroVersionWithOp(version, geOperator) +} + // NeedDistroVersionGT will skip the test unless the distro version is newer // than the specified version. // diff --git a/pkg/katatestutils/constraints_test.go b/pkg/katatestutils/constraints_test.go index c13fcb3a15..16bc63cf4b 100644 --- a/pkg/katatestutils/constraints_test.go +++ b/pkg/katatestutils/constraints_test.go @@ -1295,17 +1295,35 @@ func TestConstraintNotValidDistroVersion(t *testing.T) { result = tc.NotValid(NeedDistroVersionEquals(distroVersion)) assert.False(result) + result = tc.NotValid(NeedDistroVersionLE(higherVersion)) + assert.False(result) + + result = tc.NotValid(NeedDistroVersionLE(distroVersion)) + assert.False(result) + result = tc.NotValid(NeedDistroVersionLT(higherVersion)) assert.False(result) result = tc.NotValid(NeedDistroVersionLT(distroVersion)) assert.True(result) + result = tc.NotValid(NeedDistroVersionGE(higherVersion)) + assert.True(result) + + result = tc.NotValid(NeedDistroVersionGE(distroVersion)) + assert.False(result) + result = tc.NotValid(NeedDistroVersionGT(higherVersion)) assert.True(result) result = tc.NotValid(NeedDistroVersionGT(distroVersion)) assert.True(result) + + result = tc.NotValid(NeedDistroVersionNotEquals(higherVersion)) + assert.False(result) + + result = tc.NotValid(NeedDistroVersionNotEquals(distroVersion)) + assert.True(result) } }