Comments (1)
🤖
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: ×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 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×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.
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)
- [Proposal] config feature roadmap HOT 22
- [Feature] replace kratos metrics with otel metrics HOT 3
- [The modification of header file information of http response does not take effect] ctx.Header().Set("Content-Type", "application/octet-stream") HOT 5
- [Question] How to return a custom response json? HOT 1
- Package version dependency issue HOT 4
- go generate ./...failed HOT 5
- [Feature]Add svrType related fields in proto to protoc-gen-go-http and http transport HOT 3
- proto file used to build the api document reported an error HOT 1
- consul watch, the server is offline and will not receive any notification HOT 6
- [Feature] Add NewClient method to gRPC Client HOT 3
- [Question] DDD的最佳实践方式?包括CQRS、Clean Architecture、六边形结构 HOT 5
- [Question]请教下kratos如何定义支持上传文件接口? HOT 2
- metrics statistics and usage issues [Question] HOT 5
- `stream` response in proto failed to generate http client HOT 4
- [Feature] Add kratos errors to buf remote plugin HOT 1
- [Question] I modified it based on examples/helloworld and found that client/main.go reported an error when executing. I am not sure if it is a BUG. HOT 1
- HTTPClient proto: syntax error (line 1:1): unexpected token 404 HOT 3
- [Question] how to set response content-type as xml for one method HOT 2
- [Question] HTTP Server. extra add route do not pass middleware. HOT 1
- I a new release due soon ? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kratos.