-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
96 additions
and
30 deletions.
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,54 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestDefaultValues(t *testing.T) { | ||
cfg, err := GetConfiguration() | ||
if err != nil { | ||
t.Errorf("Error is not expected: %v", err) | ||
} | ||
|
||
checkDefaultStringValue(t, "DockerCmd", cfg.DockerCmd, "docker") | ||
checkDefaultStringValue(t, "PodmanCmd", cfg.PodmanCmd, "podman") | ||
checkDefaultStringValue(t, "TelemetryCaller", cfg.TelemetryCaller, "") | ||
checkDefaultBoolValue(t, "OdoExperimentalMode", cfg.OdoExperimentalMode, false) | ||
|
||
// Use noinit to set non initialized value as nil instead of zero-value | ||
checkNilString(t, "DevfileProxy", cfg.DevfileProxy) | ||
checkNilString(t, "Globalodoconfig", cfg.Globalodoconfig) | ||
checkNilString(t, "Globalodoconfig", cfg.Globalodoconfig) | ||
checkNilString(t, "OdoDebugTelemetryFile", cfg.OdoDebugTelemetryFile) | ||
checkNilBool(t, "OdoDisableTelemetry", cfg.OdoDisableTelemetry) | ||
checkNilString(t, "OdoTrackingConsent", cfg.OdoTrackingConsent) | ||
|
||
} | ||
|
||
func checkDefaultStringValue(t *testing.T, fieldName string, field string, def string) { | ||
if field != def { | ||
t.Errorf("default value for %q should be %q but is %q", fieldName, def, field) | ||
} | ||
|
||
} | ||
|
||
func checkDefaultBoolValue(t *testing.T, fieldName string, field bool, def bool) { | ||
if field != def { | ||
t.Errorf("default value for %q should be %v but is %v", fieldName, def, field) | ||
} | ||
|
||
} | ||
|
||
func checkNilString(t *testing.T, fieldName string, field *string) { | ||
if field != nil { | ||
t.Errorf("value for non specified env var %q should be nil but is %q", fieldName, *field) | ||
|
||
} | ||
} | ||
|
||
func checkNilBool(t *testing.T, fieldName string, field *bool) { | ||
if field != nil { | ||
t.Errorf("value for non specified env var %q should be nil but is %v", fieldName, *field) | ||
|
||
} | ||
} |
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
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
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
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