Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cjonesy committed Oct 2, 2024
1 parent 93de490 commit 162c602
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package shell_executioner

import (
"context"
"os"
"testing"
"time"

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 162c602

Please sign in to comment.