-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove support for old job command parameters Deprecated long ago, Job params: command, shell and environment_variables are now gone. This could be breaking change for installations still using those params
- Loading branch information
Victor Castell
authored
Jan 24, 2019
1 parent
ffb792b
commit be8527d
Showing
16 changed files
with
292 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_buildCmd(t *testing.T) { | ||
|
||
// test shell command | ||
cmd, err := buildCmd("echo 'test1' && echo 'success'", true, []string{}, "") | ||
assert.NoError(t, err) | ||
out, err := cmd.CombinedOutput() | ||
assert.NoError(t, err) | ||
assert.Equal(t, "test1\nsuccess\n", string(out)) | ||
|
||
// test not shell command | ||
cmd, err = buildCmd("date && echo 'success'", false, []string{}, "") | ||
assert.NoError(t, err) | ||
out, err = cmd.CombinedOutput() | ||
assert.Error(t, err) | ||
} | ||
|
||
func Test_buildCmdWithCustomEnvironmentVariables(t *testing.T) { | ||
defer func() { | ||
os.Setenv("Foo", "") | ||
}() | ||
os.Setenv("Foo", "Bar") | ||
|
||
cmd, err := buildCmd("echo $Foo && echo $He", true, []string{"Foo=Toto", "He=Ho"}, "") | ||
assert.NoError(t, err) | ||
out, err := cmd.CombinedOutput() | ||
assert.NoError(t, err) | ||
assert.Equal(t, "Toto\nHo\n", string(out)) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ import ( | |
) | ||
|
||
var ( | ||
logLevel = "debug" | ||
logLevel = "error" | ||
etcdAddr = getEnvWithDefault() | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1 @@ | ||
package dkron | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_buildCmd(t *testing.T) { | ||
|
||
// test shell command | ||
testJob1 := &Job{ | ||
Command: "echo 'test1' && echo 'success'", | ||
Shell: true, | ||
} | ||
|
||
cmd := buildCmd(testJob1) | ||
out, err := cmd.CombinedOutput() | ||
assert.NoError(t, err) | ||
assert.Equal(t, "test1\nsuccess\n", string(out)) | ||
|
||
// test not shell command | ||
testJob2 := &Job{ | ||
Command: "date && echo 'success'", | ||
Shell: false, | ||
} | ||
cmd = buildCmd(testJob2) | ||
out, err = cmd.CombinedOutput() | ||
assert.Error(t, err) | ||
} | ||
|
||
func Test_buildCmdWithCustomEnvironmentVariables(t *testing.T) { | ||
defer func() { | ||
os.Setenv("Foo", "") | ||
}() | ||
os.Setenv("Foo", "Bar") | ||
testJob := &Job{ | ||
Command: "echo $Foo && echo $He", | ||
EnvironmentVariables: []string{"Foo=Toto", "He=Ho"}, | ||
Shell: true, | ||
} | ||
|
||
cmd := buildCmd(testJob) | ||
out, err := cmd.CombinedOutput() | ||
assert.NoError(t, err) | ||
assert.Equal(t, "Toto\nHo\n", string(out)) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.