Skip to content

Commit

Permalink
chore: migrate deploy_test to integration tests in buildengine
Browse files Browse the repository at this point in the history
This tests the same things as the old test, but through slightly higher abstraction layer (cli instead of calling build engine functions directly)
  • Loading branch information
jvmakine committed Aug 26, 2024
1 parent 1e108f9 commit c22d92c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 96 deletions.
23 changes: 23 additions & 0 deletions internal/buildengine/deploy_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//go:build integration

package buildengine

import (
"testing"

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

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

// Build first to make sure the files are there.
in.Build("another"),
in.FileExists("/another/.ftl/main"),

// Test that the deployment works and starts correctly
in.Deploy("another"),
)
}
95 changes: 0 additions & 95 deletions internal/buildengine/deploy_test.go

This file was deleted.

17 changes: 16 additions & 1 deletion internal/integration/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ func WithLanguages(languages ...string) Option {
}
}

// WithTestDataDir sets the directory from which to look for test data.
//
// Defaults to "testdata/<language>" if not provided.
func WithTestDataDir(dir string) Option {
return func(o *options) {
o.testDataDir = dir
}
}

// WithFTLConfig is a Run* option that specifies the FTL config to use.
//
// This will set FTL_CONFIG for this test, then pass in the relative
Expand Down Expand Up @@ -97,6 +106,7 @@ func WithoutController() Option {

type options struct {
languages []string
testDataDir string
ftlConfigPath string
startController bool
requireJava bool
Expand Down Expand Up @@ -176,10 +186,15 @@ func run(t *testing.T, actionsOrOptions ...ActionOrOption) {
ctx = startProcess(ctx, t, filepath.Join(binDir, "ftl"), "serve", "--recreate")
}

testData := filepath.Join(cwd, "testdata", language)
if opts.testDataDir != "" {
testData = opts.testDataDir
}

ic := TestContext{
Context: ctx,
RootDir: rootDir,
testData: filepath.Join(cwd, "testdata", language),
testData: testData,
workDir: tmpDir,
binDir: binDir,
Verbs: verbs,
Expand Down

0 comments on commit c22d92c

Please sign in to comment.