@@ -7,14 +7,16 @@ package e2e_test
77import (
88 "bytes"
99 "fmt"
10+ "os"
1011 "os/exec"
12+ "path/filepath"
1113
1214 . "github.com/onsi/ginkgo/v2"
1315 . "github.com/onsi/gomega"
1416)
1517
16- // Define the mgradm binary path
17- const mgradmPath = "/workspace/bin/mgradm"
18+ // mgradmPath will hold the path to the mgradm binary.
19+ var mgradmPath string
1820
1921// runMgradmCommand is a helper function to execute mgradm and capture its output.
2022// It returns the combined stdout+stderr and an error if the command fails to run.
@@ -35,7 +37,23 @@ func runMgradmCommand(args []string) (string, error) {
3537}
3638
3739var _ = Describe ("mgradm tests" , func () {
40+ BeforeSuite (func () {
41+ cwd , err := os .Getwd ()
42+ Expect (err ).To (Succeed (), "Failed to get current working directory: %v" , err )
43+ mgradmPath = filepath .Join (cwd , "bin" , "mgradm" )
3844
45+ _ , err = os .Stat (mgradmPath )
46+ Expect (err ).To (Succeed (), "mgradm binary not found at %s. Error: %v" , mgradmPath , err )
47+
48+ GinkgoWriter .Printf ("Using mgradm: %s\n " , mgradmPath )
49+ })
50+ // Ensure that the environment is clean before each test.
51+ BeforeEach (func () {
52+ By ("Running mgradm cleanup: uninstall --force --purge-volumes --purge-images" )
53+ cleanupArgs := []string {"uninstall" , "--force" , "--purge-volumes" , "--purge-images" }
54+ output , err := runMgradmCommand (cleanupArgs )
55+ Expect (err ).To (Succeed (), "Failed to run mgradm cleanup command. Error: %v\n Output: %s" , err , output )
56+ })
3957 Context ("install command" , func () {
4058 It ("should run without error with default options" , func () {
4159 args := []string {"install" , "podman" , "--logLevel" , "debug" }
0 commit comments