We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Let's set up a simple server that responds to one endpoint /api/{value}, where value is a floating point path parameter:
/api/{value}
value
// main.go package main import ( "fmt" "net/http" ) func handler() http.Handler { mux := http.NewServeMux() mux.HandleFunc("/api/{value}", func(w http.ResponseWriter, r *http.Request) { fmt.Println(r.URL) w.WriteHeader(http.StatusOK) }) return mux } func main() { http.ListenAndServe(":8080", handler()) }
All this server does is print the requested URL. Now let's use WithPath to test this endpoint with a very large value for value:
WithPath
// main_test.go package main import ( "net/http" "net/http/httptest" "testing" "github.com/gavv/httpexpect/v2" ) func TestMainHandlers(t *testing.T) { server := httptest.NewServer(handler()) t.Cleanup(server.Close) e := httpexpect.Default(t, server.URL) e. GET("/api/{value}"). WithPath("value", 5000000.0). Expect(). Status(http.StatusOK) }
Running go test, this is what we get:
go test
$ go test /api/5e+06 PASS ok github.com/alvii147/httpexpectplayground 0.309s
Notice that the 5000000.0 has been converted to 5e+06. This is not ideal. I think we should avoid scientific notation in these cases.
5000000.0
5e+06
The text was updated successfully, but these errors were encountered:
@gavv I can fix this if you agree this is behaviour is not ideal
Sorry, something went wrong.
No branches or pull requests
Let's set up a simple server that responds to one endpoint
/api/{value}
, wherevalue
is a floating point path parameter:All this server does is print the requested URL. Now let's use
WithPath
to test this endpoint with a very large value forvalue
:Running
go test
, this is what we get:$ go test /api/5e+06 PASS ok github.com/alvii147/httpexpectplayground 0.309s
Notice that the
5000000.0
has been converted to5e+06
. This is not ideal. I think we should avoid scientific notation in these cases.The text was updated successfully, but these errors were encountered: