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.
test(buildengine): Convert
buildengine
tests into integration test (#…
…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
Showing
8 changed files
with
115 additions
and
298 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
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)), | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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,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"`, | ||
), | ||
) | ||
} |
Oops, something went wrong.