-
Notifications
You must be signed in to change notification settings - Fork 23
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
Make unmarshaling json config strict #279
Conversation
Codecov Report
@@ Coverage Diff @@
## main #279 +/- ##
==========================================
+ Coverage 66.85% 66.89% +0.03%
==========================================
Files 73 73
Lines 4152 4157 +5
==========================================
+ Hits 2776 2781 +5
Misses 1197 1197
Partials 179 179
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@@ -143,6 +143,7 @@ func RunCommand(command string) string { | |||
} | |||
|
|||
func DeserializeJSONToMap(t *testing.T, in string) config.GenericMap { | |||
t.Helper() |
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.
What is the practical result of declaring this function as a Helper function?
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.
@KalmanMeth
By marking a function as helper, when a test fails in the helper function, the line number reported will be of the caller function rather than inside the test helper function.
Consider running the following test:
package b
import (
"testing"
)
func Test(t *testing.T) {
helperMarked(t, "hello", "hi") // line 8
helperUnmarked(t, "hello", "hi")
}
func helperMarked(t *testing.T, expected, actual string) {
t.Helper()
if expected != actual {
t.Errorf("expected (%v) != actual(%v)", expected, actual)
}
}
func helperUnmarked(t *testing.T, expected, actual string) {
if expected != actual {
t.Errorf("expected (%v) != actual(%v)", expected, actual) // line 20
}
}
The result is:
=== RUN Test
b_test.go:8: expected (hello) != actual(hi)
b_test.go:20: expected (hello) != actual(hi)
--- FAIL: Test (0.00s)
FAIL
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.
nice, I didn't know that
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.
lgtm
Unmarshaling non-config related json still use the non-strict version.
This is a follow-up on #271
Fix #274