Skip to content

Commit

Permalink
fix: unbreak ci - omitempty integration test (#1459)
Browse files Browse the repository at this point in the history
```
$ just integration-tests TestHttpEncodeOmitempty
=== RUN   TestHttpEncodeOmitempty
INFO: Building ftl
    /Users/dli/Development/ftl/integration/harness_test.go:143: debug: go build -o build/release/ftl -tags release -ldflags '-X github.com/TBD54566975/ftl.Version=0.207.1-5-ge8fdce90-dirty -X github.com/TBD54566975/ftl.Timestamp=1715296195' ./cmd/ftl
INFO: Starting ftl cluster
INFO: Waiting for controller to be ready
    /Users/dli/Development/ftl/integration/harness_test.go:143: debug: Unary RPC failed: unavailable: dial tcp [::1]:8892: connect: connection refused: /xyz.block.ftl.v1.ControllerService/Status
    /Users/dli/Development/ftl/integration/harness_test.go:143: debug: Unary RPC failed: unavailable: dial tcp [::1]:8892: connect: connection refused: /xyz.block.ftl.v1.ControllerService/Status
    /Users/dli/Development/ftl/integration/harness_test.go:143: debug: Unary RPC failed: unavailable: dial tcp [::1]:8892: connect: connection refused: /xyz.block.ftl.v1.ControllerService/Status
    /Users/dli/Development/ftl/integration/harness_test.go:143: debug: info: Starting FTL with 1 controller(s)
    /Users/dli/Development/ftl/integration/harness_test.go:143: debug: Unary RPC failed: unavailable: dial tcp [::1]:8892: connect: connection refused: /xyz.block.ftl.v1.ControllerService/Status
    /Users/dli/Development/ftl/integration/harness_test.go:143: debug: info:controller0: Web console available at: http://localhost:8892
INFO: Starting test
INFO: Copying omitempty -> omitempty
INFO: Executing: ftl deploy omitempty
    /Users/dli/Development/ftl/integration/harness_test.go:143: debug: info:omitempty: Building module
    /Users/dli/Development/ftl/integration/harness_test.go:143: debug: info:omitempty: Deploying module
    /Users/dli/Development/ftl/integration/harness_test.go:143: debug: info:controller0: Deployed dpl-omitempty-2g0du8hmloj38qv3
INFO: Waiting for omitempty to become ready
INFO: HTTP GET /get
--- PASS: TestHttpEncodeOmitempty (10.98s)
PASS
ok  	github.com/TBD54566975/ftl/integration	11.216s
testing: warning: no tests to run
PASS
ok  	github.com/TBD54566975/ftl/backend/controller/cronjobs	0.337s [no tests to run]
```
  • Loading branch information
deniseli authored May 9, 2024
1 parent e8fdce9 commit e1b3c41
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 5 additions & 1 deletion integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ func TestHttpEncodeOmitempty(t *testing.T) {
copyModule("omitempty"),
deploy("omitempty"),
httpCall(http.MethodGet, "/get", jsonData(t, obj{}), func(resp *httpResponse) error {
assert.Equal(t, "{\"mustset\":\"\"}", repr.String(resp.jsonBody))
assert.Equal(t, 200, resp.status)
_, ok := resp.jsonBody["mustset"]
assert.True(t, ok)
_, ok = resp.jsonBody["error"]
assert.False(t, ok)
return nil
}),
)
Expand Down
14 changes: 9 additions & 5 deletions integration/testdata/go/omitempty/omitempty.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ package omitempty

import (
"context"
"fmt"

"ftl/builtin"

"github.com/TBD54566975/ftl/go-runtime/ftl" // Import the FTL SDK.
)

type EchoRequest struct{}
type Request struct{}

type EchoResponse struct {
type Response struct {
Error string `json:"error,omitempty"` // Should be omitted from marshaled JSON
MustSet string `json:"mustset"` // Should marshal to `"mustset":""`
}

//ftl:ingress http GET /get
func Get(ctx context.Context, req builtin.HttpRequest[EchoRequest]) (builtin.HttpResponse[EchoResponse, string], error) {
return EchoResponse{}, nil
func Get(ctx context.Context, req builtin.HttpRequest[Request]) (builtin.HttpResponse[Response, string], error) {
return builtin.HttpResponse[Response, string]{
Headers: map[string][]string{"Get": {"Header from FTL"}},
Body: ftl.Some[Response](Response{}),
}, nil
}

0 comments on commit e1b3c41

Please sign in to comment.