@@ -7,14 +7,15 @@ package e2e_test
77import (
88 "bytes"
99 "fmt"
10- "os/exec"
11-
1210 . "github.com/onsi/ginkgo/v2"
1311 . "github.com/onsi/gomega"
12+ "os"
13+ "os/exec"
14+ "path/filepath"
1415)
1516
16- // Define the mgradm binary path
17- const mgradmPath = "/workspace/bin/mgradm"
17+ // mgradmPath will hold the path to the mgradm binary.
18+ var mgradmPath string
1819
1920// runMgradmCommand is a helper function to execute mgradm and capture its output.
2021// It returns the combined stdout+stderr and an error if the command fails to run.
@@ -34,8 +35,25 @@ func runMgradmCommand(args []string) (string, error) {
3435 return output , err
3536}
3637
37- var _ = Describe ("mgradm tests" , func () {
38+ var _ = BeforeSuite (func () {
39+ cwd , err := os .Getwd ()
40+ Expect (err ).To (Succeed (), "Failed to get current working directory: %v" , err )
41+ mgradmPath = filepath .Join (cwd , "bin" , "mgradm" )
42+
43+ _ , err = os .Stat (mgradmPath )
44+ Expect (err ).To (Succeed (), "mgradm binary not found at %s. Error: %v" , mgradmPath , err )
3845
46+ GinkgoWriter .Printf ("Using mgradm: %s\n " , mgradmPath )
47+ })
48+
49+ var _ = Describe ("mgradm tests" , func () {
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