Skip to content

Commit

Permalink
feat(BUX-572): regression tests on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-4chain committed Apr 3, 2024
1 parent 107a9aa commit d7bcab7
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions regressiontests/regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"net/http"
"os"
"os/exec"
"runtime"
"testing"
"time"

Expand Down Expand Up @@ -81,14 +82,14 @@ func TestApplicationIntegration(t *testing.T) {
}

func setupApplicationBuild(t *testing.T) {
buildCmd := exec.Command("go", "build", "-o", "../cmd/bhsExecutable", "../cmd/main.go")
buildCmd := exec.Command("go", "build", "-o", pathToExecutable(), "../cmd/main.go")
if err := buildCmd.Run(); err != nil {
t.Fatalf("Failed to build the application for tests: %v", err)
}
}

func cleanupApplicationExecutable(t *testing.T) {
if err := os.Remove("../cmd/bhsExecutable"); err != nil {
if err := os.Remove(pathToExecutable()); err != nil {
t.Logf("Couldn't remove executable files: %v", err)
}
}
Expand All @@ -114,7 +115,9 @@ func setupSQLiteDatabase(t *testing.T) (*exec.Cmd, func()) {
}

func configureApplication(engine, postgresPort string) *exec.Cmd {
cmd := exec.Command("../cmd/bhsExecutable")
cmd := exec.Command(pathToExecutable())
cmd.Env = os.Environ()

if engine == "postgres" {
setPostgresEnvs(cmd, postgresPort)
} else if engine == "sqlite" {
Expand All @@ -136,7 +139,7 @@ func monitorApplicationStartup(ctx context.Context, t *testing.T, cmd *exec.Cmd)
func waitForApplicationStartup(ctx context.Context, t *testing.T, cmd *exec.Cmd) {
ticker := time.NewTicker(10 * time.Second)
defer ticker.Stop()
timeoutTimer := time.NewTimer(2 * time.Minute)
timeoutTimer := time.NewTimer(4 * time.Minute)
defer timeoutTimer.Stop()

appExitSignal := make(chan error, 1)
Expand Down Expand Up @@ -422,3 +425,11 @@ func fetchMerkleRootConfirmations(ctx context.Context, fixtures []merkleRootFixt

return confirmations.Confirmations
}

func pathToExecutable() string {
path := "../cmd/bhsExecutable"
if runtime.GOOS == "windows" {
path += ".exe"
}
return path
}

0 comments on commit d7bcab7

Please sign in to comment.