Giter Club home page Giter Club logo

Comments (1)

dosubot avatar dosubot commented on June 16, 2024 2

🤖

Hey @kvii, good to see you diving into the time zone mystery! Hope all's well on your end.

The TestEncodeValues test could be failing due to a difference in timestamps because of the way the timestamp is being encoded and compared. In the test, the timestamp is being encoded into a string format and then compared with a hardcoded string value.

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: &timestamppb.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 TestEncodeValues function in the Kratos codebase is a unit test function that tests the EncodeValues function. The EncodeValues function is used to encode the values of a complex structure into a URL-encoded string. This is useful when you want to send complex data structures as part of a URL query string.

In the TestEncodeValues function, a complex structure is created and passed to the EncodeValues function. The returned query string is then compared with the expected string. If the returned string does not match the expected string, the test fails, indicating that the EncodeValues function is not working as expected.

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&timestamp=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.

Sources


This 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.

from kratos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.