diff --git a/cmd/config/get_test.go b/cmd/config/get_test.go index 7e306552..38529c05 100644 --- a/cmd/config/get_test.go +++ b/cmd/config/get_test.go @@ -35,7 +35,7 @@ func TestConfigGetCmd_PartialKey(t *testing.T) { // Test Config Get Command fails when provided an invalid key func TestConfigGetCmd_InvalidKey(t *testing.T) { - expectedErrorPattern := `^failed to get configuration: key '.*' is not recognized as a valid configuration key\. Valid keys: [A-Za-z\.\s,]+$` + expectedErrorPattern := `(?s)^failed to get configuration: key '.*' is not recognized as a valid configuration key\. Valid keys: .*$` err := testutils_cobra.ExecutePingcli(t, "config", "get", "pingcli.invalid") testutils.CheckExpectedError(t, err, &expectedErrorPattern) } diff --git a/internal/commands/config/get_internal_test.go b/internal/commands/config/get_internal_test.go index a5cd6bfd..942ce504 100644 --- a/internal/commands/config/get_internal_test.go +++ b/internal/commands/config/get_internal_test.go @@ -23,7 +23,7 @@ func Test_RunInternalConfigGet(t *testing.T) { func Test_RunInternalConfigGet_InvalidKey(t *testing.T) { testutils_viper.InitVipers(t) - expectedErrorPattern := `^failed to get configuration: key '.*' is not recognized as a valid configuration key. Valid keys: .*$` + expectedErrorPattern := `(?s)^failed to get configuration: key '.*' is not recognized as a valid configuration key. Valid keys: .*$` err := RunInternalConfigGet("invalid-key") testutils.CheckExpectedError(t, err, &expectedErrorPattern) } diff --git a/internal/configuration/configuration.go b/internal/configuration/configuration.go index cd46d877..acd21aa9 100644 --- a/internal/configuration/configuration.go +++ b/internal/configuration/configuration.go @@ -62,12 +62,12 @@ func ExpandedViperKeys() (keys []string) { func ValidateParentViperKey(viperKey string) error { validKeys := ExpandedViperKeys() for _, vKey := range validKeys { - if vKey == viperKey { + if strings.EqualFold(vKey, viperKey) { return nil } } - validKeysStr := strings.Join(validKeys, ", ") + validKeysStr := "\n- " + strings.Join(validKeys, "\n- ") return fmt.Errorf("key '%s' is not recognized as a valid configuration key. Valid keys: %s", viperKey, validKeysStr) } diff --git a/internal/configuration/configuration_test.go b/internal/configuration/configuration_test.go index 79146ece..08862b67 100644 --- a/internal/configuration/configuration_test.go +++ b/internal/configuration/configuration_test.go @@ -50,7 +50,7 @@ func Test_ValidateParentViperKey(t *testing.T) { func Test_ValidateParentViperKey_InvalidKey(t *testing.T) { testutils_viper.InitVipers(t) - expectedErrorPattern := `^key '.*' is not recognized as a valid configuration key. Valid keys: .*$` + expectedErrorPattern := `(?s)^key '.*' is not recognized as a valid configuration key. Valid keys: .*$` err := configuration.ValidateParentViperKey("invalid-key") testutils.CheckExpectedError(t, err, &expectedErrorPattern) } @@ -59,7 +59,7 @@ func Test_ValidateParentViperKey_InvalidKey(t *testing.T) { func Test_ValidateParentViperKey_EmptyKey(t *testing.T) { testutils_viper.InitVipers(t) - expectedErrorPattern := `^key '' is not recognized as a valid configuration key. Valid keys: .*$` + expectedErrorPattern := `(?s)^key '' is not recognized as a valid configuration key. Valid keys: .*$` err := configuration.ValidateParentViperKey("") testutils.CheckExpectedError(t, err, &expectedErrorPattern) } diff --git a/internal/output/output.go b/internal/output/output.go index 47b14d6a..d4fa46d3 100644 --- a/internal/output/output.go +++ b/internal/output/output.go @@ -41,7 +41,7 @@ func SetColorize() { func Message(message string, fields map[string]interface{}) { l := logger.Get() - print(fmt.Sprintf("INFO: %s", message), fields, white, l.Info) + print(message, fields, white, l.Info) } // This function outputs green text to inform the user of success