Skip to content

Commit

Permalink
Add bash subshell with root
Browse files Browse the repository at this point in the history
  • Loading branch information
farshidtz committed Feb 20, 2024
1 parent 9852fbf commit c27423f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions utils/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,24 @@ func TestExec(t *testing.T) {
require.WithinDuration(t, start, time.Now(), timeout+500*time.Millisecond)
}

t.Run("user", func(t *testing.T) {
t.Run("user+bash", func(t *testing.T) {
testTimeout(t, "sleep 10")
})

t.Run("root", func(t *testing.T) {
// testTimeout(t, "sudo sleep 10")
t.Run("root+bash", func(t *testing.T) {
testTimeout(t, "sudo sleep 10")
})

t.Run("root", func(t *testing.T) {
timeout := 1 * time.Second

ctx, cancel := context.WithTimeout(context.Background(), timeout)
t.Cleanup(cancel)

start := time.Now()
err := goexec.CommandContext(ctx, "sudo", "sleep", "10").Run()
out, err := goexec.CommandContext(ctx, "sudo", "sleep", "10").CombinedOutput()

t.Logf("output: %s", out)
require.Error(t, err)
require.WithinDuration(t, start, time.Now(), timeout+500*time.Millisecond)
})
Expand Down

0 comments on commit c27423f

Please sign in to comment.