Skip to content
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

fix: tests that were broken from new casing change #903

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ func TestHttpIngress(t *testing.T) {
assert.True(t, ok, "good_stuff is not a string")
assert.Equal(t, "This is good stuff", goodStuff)
}),
httpCall(rd, http.MethodPost, "/users", jsonData(t, obj{"userID": 123, "postID": 345}), func(t testing.TB, resp *httpResponse) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come these didn't fail the casing change release?

Copy link
Contributor

@worstell worstell Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was bad timing - the integration tests started silently failing to execute sometime between yesterday and today because strcase.ToCamel seems to have been removed (we had to start using strcase.ToUpperCamel per this change).

here's the CI run from your casing change: https://github.com/TBD54566975/ftl/actions/runs/7827634224/job/21355851494

the test extraction step was failing with

integration/integration_test.go:164:47: undefined: strcase.ToCamel
integration/integration_test.go:273:23: undefined: strcase.ToCamel

so the run flag was provided with empty input and nothing executed. i should update the pipeline to fallback to running everything/omitting the run flag when no test cases are extracted

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay. Is the extraction step fixed so this doesn't happen again?

Also BTW I'd suggest using grep '^func Test.*' to extract the test names, mainly because it's much faster than using go test -list, which has to compile the code first before it's able to continue.

httpCall(rd, http.MethodPost, "/users", jsonData(t, obj{"userId": 123, "postId": 345}), func(t testing.TB, resp *httpResponse) {
assert.Equal(t, 201, resp.status)
assert.Equal(t, []string{"Header from FTL"}, resp.headers["Post"])
success, ok := resp.body["success"].(bool)
assert.True(t, ok, "success is not a bool")
assert.True(t, success)
}),
// contains aliased field
httpCall(rd, http.MethodPost, "/users", jsonData(t, obj{"user_id": 123, "postID": 345}), func(t testing.TB, resp *httpResponse) {
httpCall(rd, http.MethodPost, "/users", jsonData(t, obj{"user_id": 123, "postId": 345}), func(t testing.TB, resp *httpResponse) {
assert.Equal(t, 201, resp.status)
}),
httpCall(rd, http.MethodPut, "/users/123", jsonData(t, obj{"postID": "346"}), func(t testing.TB, resp *httpResponse) {
httpCall(rd, http.MethodPut, "/users/123", jsonData(t, obj{"postId": "346"}), func(t testing.TB, resp *httpResponse) {
assert.Equal(t, 200, resp.status)
assert.Equal(t, []string{"Header from FTL"}, resp.headers["Put"])
assert.Equal(t, nil, resp.body)
Expand Down
3 changes: 1 addition & 2 deletions integration/testdata/go/httpingress/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,9 @@ type PutRequest struct {
type PutResponse struct{}

//ftl:verb
//ftl:ingress http PUT /users/{userID}
//ftl:ingress http PUT /users/{userId}
func Put(ctx context.Context, req builtin.HttpRequest[PutRequest]) (builtin.HttpResponse[ftl.Unit], error) {
return builtin.HttpResponse[ftl.Unit]{
Status: 200,
Headers: map[string][]string{"Put": {"Header from FTL"}},
Body: ftl.Unit{},
}, nil
Expand Down