Require nonempty source in Execute()
This commit is contained in:
parent
6c312a1aae
commit
421271e2c3
@ -134,6 +134,9 @@ func Execute(
|
|||||||
if len(argv) == 0 {
|
if len(argv) == 0 {
|
||||||
return nil, errors.New("empty argv")
|
return nil, errors.New("empty argv")
|
||||||
}
|
}
|
||||||
|
if source == "" {
|
||||||
|
return nil, errors.New("empty source")
|
||||||
|
}
|
||||||
|
|
||||||
env = append(env, "STATE_PATH=")
|
env = append(env, "STATE_PATH=")
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ func TestExecute(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
execute := func(argv []string) ([]Item, error) {
|
execute := func(argv []string) ([]Item, error) {
|
||||||
return Execute("", argv, nil, "", time.Minute)
|
return Execute("_", argv, nil, "", time.Minute)
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := execute([]string{"true"})
|
res, err := execute([]string{"true"})
|
||||||
@ -89,7 +89,7 @@ func TestExecute(t *testing.T) {
|
|||||||
assertLen(res, 0)
|
assertLen(res, 0)
|
||||||
|
|
||||||
// Timeout
|
// Timeout
|
||||||
res, err = Execute("", []string{"sleep", "10"}, nil, "", time.Millisecond)
|
res, err = Execute("_", []string{"sleep", "10"}, nil, "", time.Millisecond)
|
||||||
assertNotNil(err)
|
assertNotNil(err)
|
||||||
assertLen(res, 0)
|
assertLen(res, 0)
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ func TestExecute(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read from stdin
|
// Read from stdin
|
||||||
res, err = Execute("", []string{"jq", "-cR", `{id: .}`}, nil, "bar", time.Minute)
|
res, err = Execute("_", []string{"jq", "-cR", `{id: .}`}, nil, "bar", time.Minute)
|
||||||
assertNil(err)
|
assertNil(err)
|
||||||
assertLen(res, 1)
|
assertLen(res, 1)
|
||||||
if res[0].Id != "bar" {
|
if res[0].Id != "bar" {
|
||||||
@ -110,7 +110,7 @@ func TestExecute(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set env
|
// Set env
|
||||||
res, err = Execute("", []string{"jq", "-cn", `{id: env.HELLO}`}, []string{"HELLO=baz"}, "", time.Minute)
|
res, err = Execute("_", []string{"jq", "-cn", `{id: env.HELLO}`}, []string{"HELLO=baz"}, "", time.Minute)
|
||||||
assertNil(err)
|
assertNil(err)
|
||||||
assertLen(res, 1)
|
assertLen(res, 1)
|
||||||
if res[0].Id != "baz" {
|
if res[0].Id != "baz" {
|
||||||
|
Loading…
Reference in New Issue
Block a user