From 162c6024e1844fa462819d7db8693f9ca5e7b638 Mon Sep 17 00:00:00 2001 From: Charlie Jones Date: Wed, 2 Oct 2024 13:59:29 -0500 Subject: [PATCH] Add tests --- .../shell_executioner_test.go | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/internal/goverseer/executioner/shell_executioner/shell_executioner_test.go b/internal/goverseer/executioner/shell_executioner/shell_executioner_test.go index cab1c6e..b8d630f 100644 --- a/internal/goverseer/executioner/shell_executioner/shell_executioner_test.go +++ b/internal/goverseer/executioner/shell_executioner/shell_executioner_test.go @@ -2,6 +2,7 @@ package shell_executioner import ( "context" + "os" "testing" "time" @@ -170,6 +171,27 @@ func TestShellExecutioner_Execute(t *testing.T) { err := executioner.Execute("test_data") assert.NoError(t, err, "Executing a valid command should not return an error") + + // This tests to ensure the workdir is still available after cleanup has run + // for the first time + err = executioner.Execute("test_data") + assert.NoError(t, err, + "Executing a valid command multiple times should not return an error") + + // Test data persistance + + testWorkDir := t.TempDir() + executioner.PersistData = true + executioner.WorkDir = testWorkDir + + err = executioner.Execute("test_persistence") + assert.NoError(t, err, + "Executing a command with PersistData should not return an error") + + dirs, _ := os.ReadDir(testWorkDir) + t.Logf("Dirs: %v", dirs) + assert.GreaterOrEqual(t, len(dirs), 1, + "Executing a command with PersistData should persist the data") } func TestShellExecutioner_Stop(t *testing.T) {