Skip to content

Commit e778856

Browse files
committed
Add documentation and fix windows unit tests
1 parent 01764d6 commit e778856

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# v1.2.0
22

3-
- Add `interval` option for `retries` which allows to execute a retry after a given period of time. I.e. `interval: 50ms`
3+
- Add reading envrionment variables from shell
4+
- Add `interval` option for `retries` which allows to execute a retry after a given period of time. I.e. `interval: 50ms`
45

56
# v1.1.0
67

docs/manual.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ config: # Config for all tests
3333
dir: /tmp #Set working directory
3434
env: # Environment variables
3535
KEY: global
36+
PATH_FROM_SHELL: ${PATH} # Read an env variable from the current shell
3637
timeout: 5000 # Timeout in ms
3738
retries: 2 # Define retries for each test
3839

pkg/cmd/command_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestCommand_AddEnvWithShellVariable(t *testing.T) {
7070
os.Setenv(TestEnvKey, "test from shell")
7171
defer os.Unsetenv(TestEnvKey)
7272

73-
c := NewCommand("echo $SOME_KEY")
73+
c := NewCommand(getCommand())
7474
c.AddEnv("SOME_KEY", fmt.Sprintf("${%s}", TestEnvKey))
7575

7676
err := c.Execute()
@@ -89,7 +89,7 @@ func TestCommand_AddMultipleEnvWithShellVariable(t *testing.T) {
8989
os.Unsetenv(TestEnvKeyName)
9090
}()
9191

92-
c := NewCommand("echo $SOME_KEY")
92+
c := NewCommand(getCommand())
9393
envValue := fmt.Sprintf("Hello ${%s}, I am ${%s}", TestEnvKeyPlanet, TestEnvKeyName)
9494
c.AddEnv("SOME_KEY", envValue)
9595

@@ -99,6 +99,14 @@ func TestCommand_AddMultipleEnvWithShellVariable(t *testing.T) {
9999
assert.Equal(t, "Hello world, I am Simon", c.Stdout())
100100
}
101101

102+
func getCommand() string {
103+
command := "echo $SOME_KEY"
104+
if runtime.GOOS == "windows" {
105+
command = "echo %SOME_KEY%"
106+
}
107+
return command
108+
}
109+
102110
func TestCommand_SetTimeoutMS_DefaultTimeout(t *testing.T) {
103111
c := NewCommand("echo test")
104112
c.SetTimeoutMS(0)

0 commit comments

Comments
 (0)