-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Test failed on different time zone. #3181
Comments
🤖 Hey @kvii, good to see you diving into the time zone mystery! Hope all's well on your end. The This could lead to a failure in the test if the timestamp is not being encoded into the exact same string format as the hardcoded string value. In the test, the timestamp is being encoded as follows: Timestamp: ×tamppb.Timestamp{Seconds: 20, Nanos: 2}, And it is being compared with the following hardcoded string value: "timestamp=1970-01-01T00%3A00%3A20.000000002Z" If the encoding of the timestamp does not result in the exact same string format, the test will fail. One possible solution could be to adjust the way the timestamp is being encoded or to adjust the hardcoded string value to match the format of the encoded timestamp. Another possible solution could be to compare the timestamps in a different way that does not rely on the string format. For example, you could compare the seconds and nanoseconds of the timestamps directly instead of comparing the string formats. However, without more information about the specific error message or the exact difference in the timestamps, it's hard to provide a more specific solution. The In the Here is the relevant code: func TestEncodeValues(t *testing.T) {
// ... complex structure creation ...
query, err := EncodeValues(in)
if err != nil {
t.Fatal(err)
}
want := "a=19&age=18&b=true&bool=false&byte=MTIz&bytes=MTIz&count=3&d=22.22&double=12.33&duration=2m0.000000022s&field=1%2C2&float=12.34&id=2233&int32=32&int64=64&map%5Bkratos%5D=https%3A%2F%2Fgo-kratos.dev%2F&map%5Bkratos_start%5D=https%3A%2F%2Fgo-kratos.dev%2Fen%2Fdocs%2Fgetting-started%2Fstart%2F&numberOne=2233&price=11.23&sex=woman&simples=3344&simples=5566&string=go-kratos×tamp=1970-01-01T00%3A00%3A20.000000002Z&uint32=32&uint64=64&very_simple.component=5566"
if got := query.Encode(); want != got {
t.Errorf("want: %s, got: %s", want, got)
}
} I hope this helps! If you need further clarification, please let me know. SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
What happened:
Test failed. Logs like below:
Note that timestamps "1970-01-01T00" and "1970-01-01T08" are different.
What you expected to happen:
Test passed.
How to reproduce it (as minimally and precisely as possible):
go test -run ^TestEncodeValues$ github.com/go-kratos/kratos/v2/encoding/form
.Anything else we need to know?:
I'll fix it soon.
Environment:
kratos -v
): v2.7.2go version
): go1.21.6 darwin/arm64cat /etc/os-release
): Mac OS Sonoma 14.3The text was updated successfully, but these errors were encountered: