|
1 | 1 | package runtime |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "github.com/stretchr/testify/assert" |
5 | | - "os" |
6 | | - "testing" |
| 4 | + "github.com/stretchr/testify/assert" |
| 5 | + "os" |
| 6 | + "testing" |
7 | 7 | ) |
8 | 8 |
|
9 | 9 | func TestRuntime_WithInheritFromShell(t *testing.T) { |
10 | | - os.Setenv("TEST_COMMANDER", "test") |
11 | | - defer os.Unsetenv("TEST_COMMANDER") |
| 10 | + os.Setenv("TEST_COMMANDER", "test") |
| 11 | + defer os.Unsetenv("TEST_COMMANDER") |
12 | 12 |
|
13 | | - test := TestCase{ |
14 | | - Command: CommandUnderTest{ |
15 | | - Cmd: "echo %TEST_COMMANDER%", |
16 | | - InheritEnv: true, |
17 | | - }, |
18 | | - } |
| 13 | + test := TestCase{ |
| 14 | + Command: CommandUnderTest{ |
| 15 | + Cmd: "echo %TEST_COMMANDER%", |
| 16 | + InheritEnv: true, |
| 17 | + }, |
| 18 | + } |
19 | 19 |
|
20 | | - got := runTest(test) |
| 20 | + got := runTest(test) |
21 | 21 |
|
22 | | - assert.Equal(t, "test", got.TestCase.Result.Stdout) |
| 22 | + assert.Equal(t, "test", got.TestCase.Result.Stdout) |
23 | 23 | } |
24 | 24 |
|
25 | 25 | func TestRuntime_WithInheritFromShell_Overwrite(t *testing.T) { |
26 | | - os.Setenv("TEST_COMMANDER", "test") |
27 | | - os.Setenv("ANOTHER_ENV", "from-parent") |
28 | | - defer func() { |
29 | | - os.Unsetenv("TEST_COMMANDER") |
30 | | - os.Unsetenv("ANOTHER_ENV") |
31 | | - }() |
32 | | - |
33 | | - test := TestCase{ |
34 | | - Command: CommandUnderTest{ |
35 | | - Cmd: "echo %TEST_COMMANDER% %ANOTHER_ENV%", |
36 | | - InheritEnv: true, |
37 | | - Env: map[string]string{"TEST_COMMANDER": "overwrite"}, |
38 | | - }, |
39 | | - } |
40 | | - |
41 | | - got := runTest(test) |
42 | | - |
43 | | - assert.Equal(t, "overwrite from-parent", got.TestCase.Result.Stdout) |
| 26 | + os.Setenv("TEST_COMMANDER", "test") |
| 27 | + os.Setenv("ANOTHER_ENV", "from-parent") |
| 28 | + defer func() { |
| 29 | + os.Unsetenv("TEST_COMMANDER") |
| 30 | + os.Unsetenv("ANOTHER_ENV") |
| 31 | + }() |
| 32 | + |
| 33 | + test := TestCase{ |
| 34 | + Command: CommandUnderTest{ |
| 35 | + Cmd: "echo %TEST_COMMANDER% %ANOTHER_ENV%", |
| 36 | + InheritEnv: true, |
| 37 | + Env: map[string]string{"TEST_COMMANDER": "overwrite"}, |
| 38 | + }, |
| 39 | + } |
| 40 | + |
| 41 | + got := runTest(test) |
| 42 | + |
| 43 | + assert.Equal(t, "overwrite from-parent", got.TestCase.Result.Stdout) |
44 | 44 | } |
0 commit comments