diff --git a/update.go b/update.go index e7d7ce9..5ea8e4e 100644 --- a/update.go +++ b/update.go @@ -1,6 +1,9 @@ package golden -import "os" +import ( + "os" + "strings" +) var truthyStrings = []string{"1", "y", "t", "yes", "on", "true"} @@ -14,7 +17,7 @@ type UpdateFunc func() bool func EnvUpdateFunc() bool { env := os.Getenv("GOLDEN_UPDATE") for _, v := range truthyStrings { - if env == v { + if strings.EqualFold(env, v) { return true } } diff --git a/update_test.go b/update_test.go index dca7ddd..3bb635e 100644 --- a/update_test.go +++ b/update_test.go @@ -90,6 +90,32 @@ var envUpdateFuncTestCases = []struct { env: map[string]string{"GOLDEN_UPDATE": "foobarnopebbq"}, want: false, }, + // Case-insensitive test cases + { + name: "GOLDEN_UPDATE set to Y (uppercase)", + env: map[string]string{"GOLDEN_UPDATE": "Y"}, + want: true, + }, + { + name: "GOLDEN_UPDATE set to TRUE (uppercase)", + env: map[string]string{"GOLDEN_UPDATE": "TRUE"}, + want: true, + }, + { + name: "GOLDEN_UPDATE set to Yes (mixed case)", + env: map[string]string{"GOLDEN_UPDATE": "Yes"}, + want: true, + }, + { + name: "GOLDEN_UPDATE set to ON (uppercase)", + env: map[string]string{"GOLDEN_UPDATE": "ON"}, + want: true, + }, + { + name: "GOLDEN_UPDATE set to TrUe (mixed case)", + env: map[string]string{"GOLDEN_UPDATE": "TrUe"}, + want: true, + }, } func TestEnvUpdateFunc(t *testing.T) {