Skip to content

Commit

Permalink
integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deniseli committed May 14, 2024
1 parent 93a1ff5 commit fd79ddc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
6 changes: 4 additions & 2 deletions integration/harness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,17 @@ func infof(format string, args ...any) {
var buildOnce sync.Once

// run an integration test.
func run(t *testing.T, actions ...action) {
func run(t *testing.T, ftlConfigPath string, actions ...action) {
tmpDir := t.TempDir()

cwd, err := os.Getwd()
assert.NoError(t, err)

rootDir := internal.GitRoot("")

t.Setenv("FTL_CONFIG", filepath.Join(tmpDir, "database/ftl-project.toml"))
if ftlConfigPath != "" {
t.Setenv("FTL_CONFIG", filepath.Join(tmpDir, ftlConfigPath))
}

// Build FTL binary
logger := log.Configure(&logWriter{logger: t}, log.Config{Level: log.Debug})
Expand Down
24 changes: 12 additions & 12 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestCron(t *testing.T) {

t.Cleanup(func() { _ = os.Remove(tmpFile) })

run(t,
run(t, "",
copyModule("cron"),
deploy("cron"),
func(t testing.TB, ic testContext) error {
Expand All @@ -41,7 +41,7 @@ func TestCron(t *testing.T) {
}

func TestLifecycle(t *testing.T) {
run(t,
run(t, "",
exec("ftl", "init", "go", ".", "echo"),
deploy("echo"),
call("echo", "echo", obj{"name": "Bob"}, func(response obj) error {
Expand All @@ -54,7 +54,7 @@ func TestLifecycle(t *testing.T) {
}

func TestInterModuleCall(t *testing.T) {
run(t,
run(t, "",
copyModule("echo"),
copyModule("time"),
deploy("time"),
Expand All @@ -73,7 +73,7 @@ func TestInterModuleCall(t *testing.T) {
}

func TestNonExportedDecls(t *testing.T) {
run(t,
run(t, "",
copyModule("time"),
deploy("time"),
copyModule("echo"),
Expand All @@ -84,10 +84,10 @@ func TestNonExportedDecls(t *testing.T) {
}

func TestDatabase(t *testing.T) {
createDB(t, "database", "testdb", false)
run(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"}, func(response obj) error { return nil }),
queryRow("testdb", "SELECT data FROM requests", "hello"),
Expand All @@ -100,7 +100,7 @@ func TestDatabase(t *testing.T) {
}

func TestSchemaGenerate(t *testing.T) {
run(t,
run(t, "",
copyDir("../schema-generate", "schema-generate"),
mkdir("build/schema-generate"),
exec("ftl", "schema", "generate", "schema-generate", "build/schema-generate"),
Expand All @@ -109,7 +109,7 @@ func TestSchemaGenerate(t *testing.T) {
}

func TestHttpEncodeOmitempty(t *testing.T) {
run(t,
run(t, "",
copyModule("omitempty"),
deploy("omitempty"),
httpCall(http.MethodGet, "/get", jsonData(t, obj{}), func(resp *httpResponse) error {
Expand All @@ -124,7 +124,7 @@ func TestHttpEncodeOmitempty(t *testing.T) {
}

func TestHttpIngress(t *testing.T) {
run(t,
run(t, "",
copyModule("httpingress"),
deploy("httpingress"),
httpCall(http.MethodGet, "/users/123/posts/456", jsonData(t, obj{}), func(resp *httpResponse) error {
Expand Down Expand Up @@ -237,14 +237,14 @@ func TestHttpIngress(t *testing.T) {
}

func TestRuntimeReflection(t *testing.T) {
run(t,
run(t, "",
copyModule("runtimereflection"),
testModule("runtimereflection"),
)
}

func TestModuleUnitTests(t *testing.T) {
run(t,
run(t, "",
copyModule("time"),
copyModule("wrapped"),
copyModule("verbtypes"),
Expand All @@ -255,7 +255,7 @@ func TestModuleUnitTests(t *testing.T) {
}

func TestLease(t *testing.T) {
run(t,
run(t, "",
copyModule("leases"),
deploy("leases"),
func(t testing.TB, ic testContext) error {
Expand Down

0 comments on commit fd79ddc

Please sign in to comment.