Skip to content

Commit

Permalink
Add documentation and fix windows unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBaeumer committed Sep 4, 2019
1 parent 01764d6 commit e778856
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# v1.2.0

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

This comment has been minimized.

Copy link
@fbartels

fbartels Sep 4, 2019

small typo here: environment

- Add `interval` option for `retries` which allows to execute a retry after a given period of time. I.e. `interval: 50ms`

# v1.1.0

Expand Down
1 change: 1 addition & 0 deletions docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ config: # Config for all tests
dir: /tmp #Set working directory
env: # Environment variables
KEY: global
PATH_FROM_SHELL: ${PATH} # Read an env variable from the current shell
timeout: 5000 # Timeout in ms
retries: 2 # Define retries for each test

Expand Down
12 changes: 10 additions & 2 deletions pkg/cmd/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestCommand_AddEnvWithShellVariable(t *testing.T) {
os.Setenv(TestEnvKey, "test from shell")
defer os.Unsetenv(TestEnvKey)

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

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

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

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

func getCommand() string {
command := "echo $SOME_KEY"
if runtime.GOOS == "windows" {
command = "echo %SOME_KEY%"
}
return command
}

func TestCommand_SetTimeoutMS_DefaultTimeout(t *testing.T) {
c := NewCommand("echo test")
c.SetTimeoutMS(0)
Expand Down

0 comments on commit e778856

Please sign in to comment.