Add small test for getFieldValue function #8
No reviewers
Labels
No labels
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/zapjournald#8
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "AlekseySVTN/zapjournald:feature/7-add_small_test_for_getFieldValue_function"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
[#7] Add small test for getFieldValue function
[#7] Fix comment lexical (by the comment of Vladimir Domnich TrueCloudLab/zapjournald#3)
feature/7-add_small_test_for_getFieldValue_functionto Add small test for getFieldValue function@ -0,0 +31,4 @@
{"Complex128", zap.Complex128("k", 1+2i), "(1+2i)"},
{"Complex64", zap.Complex64("k", 1+2i), "(1+2i)"},
{"Duration", zap.Duration("k", 1), "1"},
{"Float64", zap.Float64("k", 3.14), "4614253070214989087"},
What does it mean? Why 3.14 = 4614253070214989087 ?
It is because zap use
int64(math.Float64bits(val))
in zap.Float64() function, and the same logic in Float32() function.845ca51d5b/field.go (L138)
Overall looks good, just few notes/suggestions
@ -160,3 +160,3 @@
case zapcore.TimeType:
if f.Interface != nil {
return f.Interface
return fmt.Sprintf("%d %v", f.Integer, f.Interface)
May I ask to add a comment that shows example of this transformation?
Probably it can be seen from tests:
But having comment next to the code still would be helpful :)
Yes, of course, it will be perfect. :)
fixed
@ -0,0 +55,4 @@
}
for _, tt := range tests {
fieldValue := valueToString(getFieldValue(tt.field))
Instead of single test with multiple results I recommend:
It allows to see individual test results rather than pass/failure of single huge test.
Yes, I am fully agree with you.
fixed
@ -0,0 +70,4 @@
return nil
}
// usernameTestExample type, which are implements ArrayMarshaller interface.
Probably comment is from other type.
Yes, thank you.
fixed
71bea0a62f
to2927ca8e3d
@ -0,0 +6,4 @@
"testing"
"time"
"github.com/stretchr/testify/assert"
Can we group all non standard package together?
Yes, thank you.
Fixed.
2927ca8e3d
toe27cc2ec1e
@AlekseySVTN you are committing code as an individual developer?
Signed-off-by: Aleksey Savaitan <zxc_off@mail.ru>
e27cc2ec1e
to4c6e1f7365
@acid-ant , after small discussion with Stanislav Bogatyrev, we decided to change sign-off in these commits. Please, check update.