-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathlocal_executor_darwin_test.go
More file actions
49 lines (39 loc) · 1.01 KB
/
local_executor_darwin_test.go
File metadata and controls
49 lines (39 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package runtime
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRuntime_WithInheritFromShell(t *testing.T) {
os.Setenv("TEST_COMMANDER", "test")
defer os.Unsetenv("TEST_COMMANDER")
test := TestCase{
Command: CommandUnderTest{
Cmd: "echo $TEST_COMMANDER",
InheritEnv: true,
},
}
e := LocalExecutor{}
got, err := e.Execute(test)
assert.NoError(t, err)
assert.Equal(t, "test", got.TestCase.Result.Stdout)
}
func TestRuntime_WithInheritFromShell_Overwrite(t *testing.T) {
os.Setenv("TEST_COMMANDER", "test")
os.Setenv("ANOTHER_ENV", "from-parent")
defer func() {
os.Unsetenv("TEST_COMMANDER")
os.Unsetenv("ANOTHER_ENV")
}()
test := TestCase{
Command: CommandUnderTest{
Cmd: "echo $TEST_COMMANDER $ANOTHER_ENV",
InheritEnv: true,
Env: map[string]string{"TEST_COMMANDER": "overwrite"},
},
}
e := LocalExecutor{}
got, err := e.Execute(test)
assert.NoError(t, err)
assert.Equal(t, "overwrite from-parent", got.TestCase.Result.Stdout)
}