Merge pull request #52 from yxxhero/feat_inherit_environment_variables_for_Exec
add unittest for Exec
This commit is contained in:
commit
1bcf6a7bb1
|
|
@ -252,3 +252,18 @@ func TestRequiredEnv(t *testing.T) {
|
|||
require.Equalf(t, expected, envVal, "Expected %s to be returned when environment variable %s is set to a non-empty string", expected, envKey)
|
||||
|
||||
}
|
||||
|
||||
// TestExec tests that Exec returns the expected output.
|
||||
func TestExec(t *testing.T) {
|
||||
ctx := &Context{basePath: "."}
|
||||
|
||||
// test that the command is executed
|
||||
expected := "foo\n"
|
||||
output, err := ctx.Exec("echo", []interface{}{"foo"}, "")
|
||||
require.Nilf(t, err, "Expected no error to be returned when executing command")
|
||||
require.Equalf(t, expected, output, "Expected %s to be returned when executing command", expected)
|
||||
|
||||
// test that the command is executed with no-zero exit code
|
||||
_, err = ctx.Exec("bash", []interface{}{"-c", "exit 1"}, "")
|
||||
require.Error(t, err, "Expected error to be returned when executing command with non-zero exit code")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue