Skip to content

Commit

Permalink
chore: convert build_go_test into an integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
jvmakine committed Aug 27, 2024
1 parent ef3554f commit abcf07c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 259 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.

2 changes: 1 addition & 1 deletion internal/buildengine/testdata/type_registry_main.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit abcf07c

Please sign in to comment.