diff --git a/core/action.go b/core/action.go index 64728a2..7582f54 100644 --- a/core/action.go +++ b/core/action.go @@ -134,6 +134,9 @@ func Execute( if len(argv) == 0 { return nil, errors.New("empty argv") } + if source == "" { + return nil, errors.New("empty source") + } env = append(env, "STATE_PATH=") diff --git a/core/action_test.go b/core/action_test.go index 803a3c3..8f001e1 100644 --- a/core/action_test.go +++ b/core/action_test.go @@ -72,7 +72,7 @@ func TestExecute(t *testing.T) { } } execute := func(argv []string) ([]Item, error) { - return Execute("", argv, nil, "", time.Minute) + return Execute("_", argv, nil, "", time.Minute) } res, err := execute([]string{"true"}) @@ -89,7 +89,7 @@ func TestExecute(t *testing.T) { assertLen(res, 0) // Timeout - res, err = Execute("", []string{"sleep", "10"}, nil, "", time.Millisecond) + res, err = Execute("_", []string{"sleep", "10"}, nil, "", time.Millisecond) assertNotNil(err) assertLen(res, 0) @@ -102,7 +102,7 @@ func TestExecute(t *testing.T) { } // 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) assertLen(res, 1) if res[0].Id != "bar" { @@ -110,7 +110,7 @@ func TestExecute(t *testing.T) { } // 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) assertLen(res, 1) if res[0].Id != "baz" {