Add small test for getFieldValue function #8

Merged
Member

[#7] Add small test for getFieldValue function
[#7] Fix comment lexical (by the comment of Vladimir Domnich TrueCloudLab/zapjournald#3)

[#7] Add small test for getFieldValue function [#7] Fix comment lexical (by the comment of Vladimir Domnich TrueCloudLab/zapjournald#3)
requested reviews from alexvanin, vdomnich-yadro, dstepanov-yadro, dkirillov, ironbee, fyrchik 2023-04-12 09:54:03 +00:00
AlekseySVTN changed title from feature/7-add_small_test_for_getFieldValue_function to Add small test for getFieldValue function 2023-04-12 10:07:09 +00:00
dstepanov-yadro reviewed 2023-04-12 13:12:17 +00:00
@ -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 ?

What does it mean? Why 3.14 = 4614253070214989087 ?
Author
Member

It is because zap use int64(math.Float64bits(val)) in zap.Float64() function, and the same logic in Float32() function.
845ca51d5b/field.go (L138)

It is because zap use ```int64(math.Float64bits(val))``` in zap.Float64() function, and the same logic in Float32() function. https://github.com/uber-go/zap/blob/845ca51d5b8d9fed9fe14f35ab13b6b160d5762d/field.go#L138
dstepanov-yadro marked this conversation as resolved
vdomnich-yadro approved these changes 2023-04-13 07:40:57 +00:00
vdomnich-yadro left a comment
Member

Overall looks good, just few notes/suggestions

Overall looks good, just few notes/suggestions
zapjournald.go Outdated
@ -160,3 +160,3 @@
case zapcore.TimeType:
if f.Interface != nil {
return f.Interface
return fmt.Sprintf("%d %v", f.Integer, f.Interface)
Member

May I ask to add a comment that shows example of this transformation?

Probably it can be seen from tests:

{"Time", zap.Time("k", time.Unix(0, 0).In(time.UTC)), "0 UTC"}
{"TimeFull", zap.Time("k", time.Time{}), "0001-01-01 00:00:00 +0000 UTC"}

But having comment next to the code still would be helpful :)

May I ask to add a comment that shows example of this transformation? Probably it can be seen from tests: ``` {"Time", zap.Time("k", time.Unix(0, 0).In(time.UTC)), "0 UTC"} {"TimeFull", zap.Time("k", time.Time{}), "0001-01-01 00:00:00 +0000 UTC"} ``` But having comment next to the code still would be helpful :)
Author
Member

Yes, of course, it will be perfect. :)

Yes, of course, it will be perfect. :)
Author
Member

fixed

fixed
vdomnich-yadro marked this conversation as resolved
@ -0,0 +55,4 @@
}
for _, tt := range tests {
fieldValue := valueToString(getFieldValue(tt.field))
Member

Instead of single test with multiple results I recommend:

for _, test := range tests {
	t.Run(test.name, func(t *testing.T) {
    	// do my testing stuff
	})
}

It allows to see individual test results rather than pass/failure of single huge test.

Instead of single test with multiple results I recommend: ``` for _, test := range tests { t.Run(test.name, func(t *testing.T) { // do my testing stuff }) } ``` It allows to see individual test results rather than pass/failure of single huge test.
Author
Member

Yes, I am fully agree with you.

Yes, I am fully agree with you.
Author
Member

fixed

fixed
vdomnich-yadro marked this conversation as resolved
@ -0,0 +70,4 @@
return nil
}
// usernameTestExample type, which are implements ArrayMarshaller interface.
Member

Probably comment is from other type.

Probably comment is from other type.
Author
Member

Yes, thank you.

Yes, thank you.
Author
Member

fixed

fixed
vdomnich-yadro marked this conversation as resolved
dstepanov-yadro approved these changes 2023-04-13 07:57:49 +00:00
AlekseySVTN force-pushed feature/7-add_small_test_for_getFieldValue_function from 71bea0a62f to 2927ca8e3d 2023-04-13 07:58:24 +00:00 Compare
requested review from vdomnich-yadro 2023-04-13 07:59:30 +00:00
vdomnich-yadro approved these changes 2023-04-13 08:14:04 +00:00
dkirillov reviewed 2023-04-13 09:22:35 +00:00
@ -0,0 +6,4 @@
"testing"
"time"
"github.com/stretchr/testify/assert"
Member

Can we group all non standard package together?

Can we group all non standard package together?
Author
Member

Yes, thank you.
Fixed.

Yes, thank you. Fixed.
AlekseySVTN force-pushed feature/7-add_small_test_for_getFieldValue_function from 2927ca8e3d to e27cc2ec1e 2023-04-13 10:09:08 +00:00 Compare
Member

@AlekseySVTN you are committing code as an individual developer?
Signed-off-by: Aleksey Savaitan <zxc_off@mail.ru>

@AlekseySVTN you are committing code as an individual developer? `Signed-off-by: Aleksey Savaitan <zxc_off@mail.ru>`
AlekseySVTN force-pushed feature/7-add_small_test_for_getFieldValue_function from e27cc2ec1e to 4c6e1f7365 2023-04-14 08:01:07 +00:00 Compare
Author
Member

@acid-ant , after small discussion with Stanislav Bogatyrev, we decided to change sign-off in these commits. Please, check update.

@acid-ant , after small discussion with Stanislav Bogatyrev, we decided to change sign-off in these commits. Please, check update.
acid-ant approved these changes 2023-04-14 12:09:11 +00:00
AlekseySVTN merged commit 4c6e1f7365 into master 2023-04-14 12:48:06 +00:00
AlekseySVTN deleted branch feature/7-add_small_test_for_getFieldValue_function 2023-04-14 12:48:07 +00:00
Sign in to join this conversation.
No description provided.