Skip to content

Commit

Permalink
test(buildengine): Convert buildengine tests into integration test (#…
Browse files Browse the repository at this point in the history
…2508)

See #1585

I left engine_test in place, as there was one test for graph
construction that could not be done nicely as an integration test.
  • Loading branch information
jvmakine authored Aug 27, 2024
1 parent 86ab6fa commit 192d8e2
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 298 deletions.
57 changes: 57 additions & 0 deletions internal/buildengine/build_go_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//go:build integration

package buildengine

import (
"os"
"testing"

"github.com/alecthomas/assert/v2"

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

func TestGoBuildClearsBuildDir(t *testing.T) {
file := "./another/.ftl/test-clear-build.tmp"
in.Run(t,
in.WithTestDataDir("testdata"),
in.CopyModule("another"),
in.Build("another"),
in.WriteFile(file, []byte{1}),
in.FileExists(file),
in.Build("another"),
in.ExpectError(in.FileExists(file), "no such file"),
)
}

func TestExternalType(t *testing.T) {
in.Run(t,
in.WithTestDataDir("testdata"),
in.CopyModule("external"),
in.ExpectError(in.Build("external"),
`unsupported type "time.Month" for field "Month"`,
`unsupported external type "time.Month"; see FTL docs on using external types: tbd54566975.github.io/ftl/docs/reference/externaltypes/`,
`unsupported response type "ftl/external.ExternalResponse"`,
),
)
}

func TestGeneratedTypeRegistry(t *testing.T) {
expected, err := os.ReadFile("testdata/type_registry_main.go")
assert.NoError(t, err)

file := "other/.ftl/go/main/main.go"

in.Run(t,
in.WithTestDataDir("testdata"),
// Deploy dependency
in.CopyModule("another"),
in.Deploy("another"),
// Build the module under test
in.CopyModule("other"),
in.ExpectError(in.FileExists(file), "no such file"),
in.Build("other"),
// Validate the generated main.go
in.FileContent(file, string(expected)),
)
}
91 changes: 0 additions & 91 deletions internal/buildengine/build_go_test.go

This file was deleted.

167 changes: 0 additions & 167 deletions internal/buildengine/build_test.go

This file was deleted.

35 changes: 35 additions & 0 deletions internal/buildengine/engine_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//go:build integration

package buildengine_test

import (
"testing"

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

func TestCycleDetection(t *testing.T) {
in.Run(t,
in.WithTestDataDir("testdata"),
in.CopyModule("depcycle1"),
in.CopyModule("depcycle2"),

in.ExpectError(
in.Build("depcycle1", "depcycle2"),
`detected a module dependency cycle that impacts these modules:`,
),
)
}

func TestInt64BuildError(t *testing.T) {
in.Run(t,
in.WithTestDataDir("testdata"),
in.CopyModule("integer"),

in.ExpectError(
in.Build("integer"),
`unsupported type "int64" for field "Input"`,
`unsupported type "int64" for field "Output"`,
),
)
}
Loading

0 comments on commit 192d8e2

Please sign in to comment.