Skip to content

Commit

Permalink
fix: use @SQLDatasource declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Mar 3, 2025
1 parent bcffdad commit daa233d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
8 changes: 7 additions & 1 deletion internal/integration/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
)

const dumpPath = "/tmp/ftl-kube-report"
const appDumpPatch = "/tmp/ftl-test-app"

var RedPandaBrokers = []string{"127.0.0.1:19092"}

Expand Down Expand Up @@ -363,7 +364,7 @@ func run(t *testing.T, actionsOrOptions ...ActionOrOption) {
kubeClient: optional.Ptr(kubeClient),
}
defer dumpKubePods(ctx, ic.kubeClient, ic.kubeNamespace)

defer dumpApp(t, ic)
if opts.startController || opts.kube {
ic.Admin = admin
ic.Schema = schema
Expand Down Expand Up @@ -423,6 +424,11 @@ func run(t *testing.T, actionsOrOptions ...ActionOrOption) {
}
}

func dumpApp(t testing.TB, ic TestContext) {
err := copy.Copy(ic.WorkingDir(), appDumpPatch)
assert.NoError(t, err)
}

func attemptToResetPubSub(admin sarama.ClusterAdmin) error {
groups, err := admin.ListConsumerGroups()
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
/**
* Annotation to specify a SQL datasource.
*
* This can be added anywhere in your application, but it is recommended to add it to a package-info.java file
* at the root of your package hierarchy.
* This can be added anywhere in your application.
*
*/
@Retention(RetentionPolicy.RUNTIME)
Expand Down
15 changes: 7 additions & 8 deletions jvm-runtime/jvm_hot_reload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,13 @@ func TestLifecycleJVM(t *testing.T) {
in.Call("echo", "hello", map[string]string{"name": "Bob"}, func(t testing.TB, response map[string]string) {
assert.Equal(t, "Bye, Bob!", response["message"])
}),
// Now lets add a database, add the ftl config
in.EditFile("echo", func(content []byte) []byte {
return []byte(`
quarkus.datasource.testdb.db-kind=postgresql
quarkus.hibernate-orm.datasource=testdb
`)
}, "src/main/resources/application.properties"),

// Now lets add the DB
in.IfLanguage("java", in.EditFile("echo", func(content []byte) []byte {
return []byte(strings.ReplaceAll(string(content), "@Export", "@Export\n\n@SQLDatasource(name = \"testdb\", type = SQLDatabaseType.POSTGRESQL)"))
}, "src/main/java/ftl/echo/Echo.java")),
in.IfLanguage("kotlin", in.EditFile("echo", func(content []byte) []byte {
return []byte(strings.ReplaceAll(string(content), "@Export", "@Export\n\n@SQLDatasource(name = \"testdb\", type = SQLDatabaseType.POSTGRESQL)"))
}, "src/main/kotlin/ftl/echo/Echo.kt")),
// Create a new datasource
in.Exec("ftl", "postgres", "new", "echo.testdb"),

Expand Down

0 comments on commit daa233d

Please sign in to comment.