Skip to content

Commit

Permalink
test(fmannotator): workaround for issue which expects a valid config.…
Browse files Browse the repository at this point in the history
…json
  • Loading branch information
mmalenic committed Sep 3, 2024
1 parent 3e1bee3 commit 1d2baf1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use crate::Config;
pub async fn generate_entities() -> Result<()> {
let config = Config::load()?;

println!("{:#?}", config);

let out_dir = config.out_dir;
let command: &[&_] = &[
"sea-orm-cli",
Expand Down
18 changes: 13 additions & 5 deletions lib/workload/stateless/stacks/fmannotator/internal/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/testcontainers/testcontainers-go/wait"
"github.com/umccr/orcabus/lib/workload/stateless/stacks/fmannotator/schema/orcabus_workflowmanager/workflowrunstatechange"
"os"
"path"
"path/filepath"
"runtime"
"strconv"
Expand Down Expand Up @@ -41,11 +42,12 @@ func setupService(t *testing.T, buildContext string, port nat.Port, wait wait.St
containerName := strings.ReplaceAll(strings.Trim(buildContext, "./"), "/", "_")
req := testcontainers.ContainerRequest{
FromDockerfile: testcontainers.FromDockerfile{
Context: buildContext,
Repo: containerName,
Tag: containerName,
BuildArgs: args,
KeepImage: true,
Context: buildContext,
Repo: containerName,
Tag: containerName,
BuildArgs: args,
KeepImage: true,
PrintBuildLog: true,
},
ExposedPorts: []string{port.Port()},
Env: env,
Expand Down Expand Up @@ -81,6 +83,12 @@ func SetupFileManager(t *testing.T) *sql.DB {
t.Setenv("TESTCONTAINERS_RYUK_CONNECTION_TIMEOUT", "10m")
t.Setenv("TESTCONTAINERS_RYUK_RECONNECTION_TIMEOUT", "5m")

// This works around an issue in test containers which requires the presence of a config.json file.
dir := t.TempDir()
err := os.WriteFile(path.Join(dir, "config.json"), []byte("{}"), 0666)
require.NoError(t, err)
t.Setenv("DOCKER_CONFIG", dir)

// Database
testDatabaseName := fmt.Sprintf("filemanager_test_%v", strings.ReplaceAll(uuid.New().String(), "-", "_"))
databaseIp, port := setupService(t, "../filemanager/database", "4321", wait.ForLog("database system is ready to accept connections").
Expand Down

0 comments on commit 1d2baf1

Please sign in to comment.