-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix (config) : Display message when user tries to set okd preset on a…
…rm (#3389) Add additional handling in validatePreset method for failing the validation when `okd` preset is provided on arm architecture. Validation would fail with message directing user to use other preset values. Signed-off-by: Rohan Kumar <[email protected]>
- Loading branch information
1 parent
ce1b636
commit 602c1f4
Showing
2 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestValidatePresetWithVariousPresetValues(t *testing.T) { | ||
tests := []struct { | ||
presetValue string | ||
validationPassed bool | ||
validationMessage string | ||
}{ | ||
{"openshift", true, ""}, | ||
{"microshift", true, ""}, | ||
{"unknown", false, "Unknown preset"}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.presetValue, func(t *testing.T) { | ||
// When | ||
validationPass, validationMessage := validatePreset(tt.presetValue) | ||
|
||
// Then | ||
assert.Equal(t, tt.validationPassed, validationPass) | ||
assert.Contains(t, validationMessage, tt.validationMessage) | ||
}) | ||
} | ||
} | ||
|
||
func TestValidationPreset_WhenOKDProvidedOnNonArmArchitecture_thenValidationSuccessful(t *testing.T) { | ||
// Given | ||
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" { | ||
t.Skip("Skipping test; running on ARM architecture") | ||
} | ||
// When | ||
validationPass, validationMessage := validatePreset("okd") | ||
// Then | ||
assert.Equal(t, true, validationPass) | ||
assert.Equal(t, "", validationMessage) | ||
} | ||
|
||
func TestValidationPreset_WhenOKDProvidedOnArmArchitecture_thenValidationFailure(t *testing.T) { | ||
// Given | ||
if runtime.GOARCH != "arm" && runtime.GOARCH != "arm64" { | ||
t.Skip("Skipping test; not running on ARM architecture") | ||
} | ||
// When | ||
validationPass, validationMessage := validatePreset("okd") | ||
// Then | ||
assert.Equal(t, false, validationPass) | ||
assert.Equal(t, fmt.Sprintf("preset 'okd' is not supported on %s architecture, please use different preset value", runtime.GOARCH), validationMessage) | ||
} |