Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Simplify and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Nov 20, 2023
1 parent 5df8a23 commit 8bf1ebf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
1 change: 0 additions & 1 deletion test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func TestEthTransfer(t *testing.T) {
defer func() {
msg, err := cluster.stop()
require.NoError(t, err, string(msg))
require.NoError(t, cluster.reset())
}()

log.Info("restarting docker containers for the test")
Expand Down
24 changes: 9 additions & 15 deletions test/test-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,33 @@ import (
"path/filepath"
)

// testCluster represents abstraction that enables management of Docker containers
type testCluster struct {
path string
origWorkDir string
path string
}

func newTestCluster(path string) (*testCluster, error) {
workDir, err := os.Getwd()
if err != nil {
return nil, err
}

if path == "" {
workDir, err := os.Getwd()
if err != nil {
return nil, err
}
path = filepath.Dir(workDir)
}

if err := os.Chdir(path); err != nil {
return nil, err
}

return &testCluster{
path: path,
origWorkDir: workDir,
}, nil
return &testCluster{path: path}, nil
}

// start starts required Docker containers
func (t *testCluster) start() ([]byte, error) {
return exec.Command("make", "run-docker").CombinedOutput()
}

// stop stop and destroys running Docker containers
func (t *testCluster) stop() ([]byte, error) {
return exec.Command("make", "stop-docker").CombinedOutput()
}

func (t *testCluster) reset() error {
return os.Chdir(t.origWorkDir)
}

0 comments on commit 8bf1ebf

Please sign in to comment.