generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: relocate console service and add integration tests (#2199)
- Adds `ConsoleService` to integration testcontext - Adds a test for `GetModules` to help catch errors that will cause the console to not load. In a future refactor, we will fix the console to not fail from just a single call like this.
- Loading branch information
1 parent
0777796
commit 78f3a13
Showing
10 changed files
with
273 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//go:build integration | ||
|
||
package console_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"connectrpc.com/connect" | ||
pbconsole "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/console" | ||
in "github.com/TBD54566975/ftl/integration" | ||
"github.com/alecthomas/assert/v2" | ||
) | ||
|
||
// GetModules calls console service GetModules and returns the response. | ||
// | ||
// This action is defined here vs. actions.go because it is only used in this test file. | ||
func GetModules(onResponse func(t testing.TB, resp *connect.Response[pbconsole.GetModulesResponse])) in.Action { | ||
return func(t testing.TB, ic in.TestContext) { | ||
in.Infof("GetModules") | ||
modules, err := ic.Console.GetModules(ic.Context, &connect.Request[pbconsole.GetModulesRequest]{}) | ||
assert.NoError(t, err) | ||
onResponse(t, modules) | ||
} | ||
} | ||
|
||
func TestConsoleGetModules(t *testing.T) { | ||
in.Run(t, "", | ||
in.CopyModule("console"), | ||
in.Deploy("console"), | ||
GetModules(func(t testing.TB, resp *connect.Response[pbconsole.GetModulesResponse]) { | ||
assert.Equal(t, 1, len(resp.Msg.Modules)) | ||
assert.Equal(t, "console", resp.Msg.Modules[0].Name) | ||
}), | ||
) | ||
} |
2 changes: 1 addition & 1 deletion
2
backend/controller/console_test.go → backend/controller/console/console_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package controller | ||
package console | ||
|
||
import ( | ||
"testing" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package console | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"ftl/builtin" | ||
|
||
lib "github.com/TBD54566975/ftl/backend/controller/console/testdata/go" | ||
"github.com/TBD54566975/ftl/go-runtime/ftl" // Import the FTL SDK. | ||
) | ||
|
||
type External = lib.External | ||
|
||
type Response struct { | ||
Message string | ||
} | ||
|
||
//ftl:ingress http GET /test | ||
func Get(ctx context.Context, req builtin.HttpRequest[External]) (builtin.HttpResponse[Response, string], error) { | ||
return builtin.HttpResponse[Response, string]{ | ||
Body: ftl.Some(Response{ | ||
Message: fmt.Sprintf("Hello, %s", req.Body.Message), | ||
}), | ||
}, nil | ||
} | ||
|
||
//ftl:verb | ||
func Verb(ctx context.Context, req External) (External, error) { | ||
return External{ | ||
Message: fmt.Sprintf("Hello, %s", req.Message), | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module = "console" | ||
language = "go" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module ftl/console | ||
|
||
go 1.22.2 | ||
|
||
require github.com/TBD54566975/ftl v0.189.0 | ||
|
||
require ( | ||
connectrpc.com/connect v1.16.2 // indirect | ||
connectrpc.com/grpcreflect v1.2.0 // indirect | ||
github.com/alecthomas/atomic v0.1.0-alpha2 // indirect | ||
github.com/alecthomas/concurrency v0.0.2 // indirect | ||
github.com/alecthomas/participle/v2 v2.1.1 // indirect | ||
github.com/alecthomas/types v0.16.0 // indirect | ||
github.com/alessio/shellescape v1.4.2 // indirect | ||
github.com/benbjohnson/clock v1.3.5 // indirect | ||
github.com/danieljoos/wincred v1.2.0 // indirect | ||
github.com/go-logr/logr v1.4.2 // indirect | ||
github.com/go-logr/stdr v1.2.2 // indirect | ||
github.com/godbus/dbus/v5 v5.1.0 // indirect | ||
github.com/hashicorp/cronexpr v1.1.2 // indirect | ||
github.com/jackc/pgpassfile v1.0.0 // indirect | ||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect | ||
github.com/jackc/pgx/v5 v5.6.0 // indirect | ||
github.com/jackc/puddle/v2 v2.2.1 // indirect | ||
github.com/jpillora/backoff v1.0.0 // indirect | ||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/multiformats/go-base36 v0.2.0 // indirect | ||
github.com/puzpuzpuz/xsync/v3 v3.4.0 // indirect | ||
github.com/swaggest/jsonschema-go v0.3.72 // indirect | ||
github.com/swaggest/refl v1.3.0 // indirect | ||
github.com/zalando/go-keyring v0.2.5 // indirect | ||
go.opentelemetry.io/otel v1.28.0 // indirect | ||
go.opentelemetry.io/otel/metric v1.28.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.28.0 // indirect | ||
golang.org/x/crypto v0.25.0 // indirect | ||
golang.org/x/exp v0.0.0-20240707233637-46b078467d37 // indirect | ||
golang.org/x/mod v0.19.0 // indirect | ||
golang.org/x/net v0.27.0 // indirect | ||
golang.org/x/sync v0.7.0 // indirect | ||
golang.org/x/sys v0.22.0 // indirect | ||
golang.org/x/text v0.16.0 // indirect | ||
google.golang.org/protobuf v1.34.2 // indirect | ||
) | ||
|
||
replace github.com/TBD54566975/ftl => ./../../../../../.. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package lib | ||
|
||
type External struct { | ||
Message string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters