Skip to content

Commit

Permalink
moving database tests to sql
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanj-square committed May 31, 2024
1 parent 4cb55ad commit 1daf47d
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 17 deletions.
25 changes: 25 additions & 0 deletions backend/controller/sql/database_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//go:build integration

package sql_test

import (
"testing"

in "github.com/TBD54566975/ftl/integration"
)

func TestDatabase(t *testing.T) {
in.Run(t, "database/ftl-project.toml",
// deploy real module against "testdb"
in.CopyModule("database"),
in.CreateDBAction("database", "testdb", false),
in.Deploy("database"),
in.Call("database", "insert", in.Obj{"data": "hello"}, nil),
in.QueryRow("testdb", "SELECT data FROM requests", "hello"),

// run tests which should only affect "testdb_test"
in.CreateDBAction("database", "testdb", true),
in.ExecModuleTest("database"),
in.QueryRow("testdb", "SELECT data FROM requests", "hello"),
)
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ require (
google.golang.org/protobuf v1.34.1 // indirect
)

replace github.com/TBD54566975/ftl => ../../../..
replace github.com/TBD54566975/ftl => ../../../../../..
File renamed without changes.
16 changes: 0 additions & 16 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,6 @@ func TestUndefinedExportedDecls(t *testing.T) {
)
}

func TestDatabase(t *testing.T) {
Run(t, "database/ftl-project.toml",
// deploy real module against "testdb"
CopyModule("database"),
CreateDBAction("database", "testdb", false),
Deploy("database"),
Call("database", "insert", Obj{"data": "hello"}, nil),
QueryRow("testdb", "SELECT data FROM requests", "hello"),

// run tests which should only affect "testdb_test"
CreateDBAction("database", "testdb", true),
ExecModuleTest("database"),
QueryRow("testdb", "SELECT data FROM requests", "hello"),
)
}

func TestSchemaGenerate(t *testing.T) {
Run(t, "",
CopyDir("../schema-generate", "schema-generate"),
Expand Down

0 comments on commit 1daf47d

Please sign in to comment.