-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove TF_SCHEMA_PANIC_ON_ERR #462
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8209,48 +8209,26 @@ func TestValidateAtLeastOneOfAttributes(t *testing.T) { | |
} | ||
} | ||
|
||
func Test_panicOnErrDefaultTrue(t *testing.T) { | ||
oldEnv := os.Getenv(PanicOnErr) | ||
func TestPanicOnErrorDefaultsFalse(t *testing.T) { | ||
oldEnv := os.Getenv("TF_ACC") | ||
|
||
os.Setenv(PanicOnErr, "") | ||
if !schemaMap(nil).panicOnError() { | ||
t.Fatalf("Empty %s should default to true", PanicOnErr) | ||
} | ||
|
||
os.Setenv(PanicOnErr, oldEnv) | ||
} | ||
|
||
func Test_panicOnErrParsableTrue(t *testing.T) { | ||
oldEnv := os.Getenv(PanicOnErr) | ||
|
||
os.Setenv(PanicOnErr, "true") | ||
if !schemaMap(nil).panicOnError() { | ||
t.Fatalf("Parsable truthy %s should return true", PanicOnErr) | ||
} | ||
|
||
os.Setenv(PanicOnErr, oldEnv) | ||
} | ||
|
||
func Test_panicOnErrParsableFalse(t *testing.T) { | ||
oldEnv := os.Getenv(PanicOnErr) | ||
|
||
os.Setenv(PanicOnErr, "false") | ||
os.Setenv("TF_ACC", "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh god this is just asking for a race condition problem 😭 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, these unit tests aren't super high value so we could ditch the tests if you find this too "anti pattern" |
||
if schemaMap(nil).panicOnError() { | ||
t.Fatalf("Parsable falsy %s should return false", PanicOnErr) | ||
t.Fatalf("panicOnError should be false when TF_ACC is empty") | ||
} | ||
|
||
os.Setenv(PanicOnErr, oldEnv) | ||
os.Setenv("TF_ACC", oldEnv) | ||
} | ||
|
||
func Test_panicOnErrUnparsableDefaultTrue(t *testing.T) { | ||
oldEnv := os.Getenv(PanicOnErr) | ||
func TestPanicOnErrorTF_ACCSet(t *testing.T) { | ||
oldEnv := os.Getenv("TF_ACC") | ||
|
||
os.Setenv(PanicOnErr, "FOO") | ||
os.Setenv("TF_ACC", "1") | ||
if !schemaMap(nil).panicOnError() { | ||
t.Fatalf("Any set value for %s should return true", PanicOnErr) | ||
t.Fatalf("panicOnError should be true when TF_ACC is not empty") | ||
} | ||
|
||
os.Setenv(PanicOnErr, oldEnv) | ||
os.Setenv("TF_ACC", oldEnv) | ||
} | ||
|
||
func TestValidateRequiredWithAttributes(t *testing.T) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not referenced anywhere else