diff --git a/internal/runner/parallel/parallel_test.go b/internal/runner/parallel/parallel_test.go index 8b238cab..a8565509 100644 --- a/internal/runner/parallel/parallel_test.go +++ b/internal/runner/parallel/parallel_test.go @@ -15,7 +15,7 @@ import ( "github.com/flowexec/flow/internal/runner/engine/mocks" "github.com/flowexec/flow/internal/runner/parallel" testUtils "github.com/flowexec/flow/tests/utils" - "github.com/flowexec/flow/tools/builder" + "github.com/flowexec/flow/tests/utils/builder" "github.com/flowexec/flow/types/executable" ) diff --git a/internal/runner/serial/serial_test.go b/internal/runner/serial/serial_test.go index 4eb58fdd..8a2a28b9 100644 --- a/internal/runner/serial/serial_test.go +++ b/internal/runner/serial/serial_test.go @@ -15,7 +15,7 @@ import ( "github.com/flowexec/flow/internal/runner/engine/mocks" "github.com/flowexec/flow/internal/runner/serial" testUtils "github.com/flowexec/flow/tests/utils" - "github.com/flowexec/flow/tools/builder" + "github.com/flowexec/flow/tests/utils/builder" "github.com/flowexec/flow/types/executable" ) diff --git a/tools/builder/builder.go b/tests/utils/builder/builder.go similarity index 100% rename from tools/builder/builder.go rename to tests/utils/builder/builder.go diff --git a/tools/builder/exec.go b/tests/utils/builder/exec.go similarity index 70% rename from tools/builder/exec.go rename to tests/utils/builder/exec.go index de663408..16f5191e 100644 --- a/tools/builder/exec.go +++ b/tests/utils/builder/exec.go @@ -84,14 +84,11 @@ func ExecWithExit(opts ...Option) *executable.Executable { func ExecWithTimeout(opts ...Option) *executable.Executable { name := "with-timeout" timeout := 3 * time.Second - docstring := "The `timeout` field can be set to limit the amount of time the executable will run.\n" + - "If the executable runs longer than the timeout, it will be killed and the execution will fail." e := &executable.Executable{ - Verb: "run", - Name: name, - Visibility: privateExecVisibility(), - Description: docstring, - Timeout: &timeout, + Verb: "run", + Name: name, + Visibility: privateExecVisibility(), + Timeout: &timeout, Exec: &executable.ExecExecutableType{ Cmd: fmt.Sprintf("sleep %d", int(timeout.Seconds()+10)), }, @@ -105,17 +102,10 @@ func ExecWithTimeout(opts ...Option) *executable.Executable { func ExecWithTmpDir(opts ...Option) *executable.Executable { name := "with-tmp-dir" - docstring := fmt.Sprintf( - "Executables will be run from a new temporary direction when the `dir` field is set to `%s`.\n"+ - "If the executable is a parallel or serial executable, all sub-executables will run from the same temporary directory.\n"+ - "Any files created during the execution will be deleted after the executable completes.", - executable.TmpDirLabel, - ) e := &executable.Executable{ - Verb: "run", - Name: name, - Visibility: privateExecVisibility(), - Description: docstring, + Verb: "run", + Name: name, + Visibility: privateExecVisibility(), Exec: &executable.ExecExecutableType{ Dir: executable.Directory(executable.TmpDirLabel), Cmd: fmt.Sprintf("echo 'hello from %[1]s';mkdir %[1]s; cd %[1]s; pwd", name), @@ -140,19 +130,10 @@ func ExecWithArgs(opts ...Option) *executable.Executable { argCmds = append(argCmds, fmt.Sprintf("echo 'flag=%s, key=%s'", arg.Flag, arg.EnvKey)) } } - docstring := "Command line arguments can be passed to the executable using the `args` field.\n" + - "Arguments can be positional or flags, and can have default values.\n" + - "**You must specify the `envKey` field for each argument and one of `pos` or `flag`** " + - "The value of the argument will be available in the environment variable specified by `envKey`.\n" + - "The first positional argument is at position 1 and following arguments are at increasing positions. " + - "Flags are specified with the defined flag value and is followed by `=` and it's value (no spaces).\n" + - "If a default value is provided, it will be used if the argument is not provided. The executable will " + - "fail if a required argument is not provided." e := &executable.Executable{ - Verb: "run", - Name: name, - Visibility: privateExecVisibility(), - Description: docstring, + Verb: "run", + Name: name, + Visibility: privateExecVisibility(), Exec: &executable.ExecExecutableType{ Args: args, Cmd: fmt.Sprintf("echo 'hello from %s'; %s", name, strings.Join(argCmds, "; ")), @@ -167,11 +148,6 @@ func ExecWithArgs(opts ...Option) *executable.Executable { func ExecWithParams(opts ...Option) *executable.Executable { name := "with-params" - docstring := "Parameters can be passed to the executable using the `params` field.\n" + - "Parameters can be text, secrets, or prompts. Text parameters will be available in the environment variable " + - "specified by `envKey`. Secret parameters will be resolved from the secret store and will be available in the " + - "environment variable specified by `envKey`. Prompt parameters will prompt the user for a value and will be " + - "available in the environment variable specified by `envKey`." params := executable.ParameterList{ {EnvKey: "PARAM1", Text: "value1"}, {EnvKey: "PARAM2", SecretRef: "flow-example-secret"}, @@ -195,10 +171,9 @@ func ExecWithParams(opts ...Option) *executable.Executable { } } e := &executable.Executable{ - Verb: "run", - Name: name, - Visibility: privateExecVisibility(), - Description: docstring, + Verb: "run", + Name: name, + Visibility: privateExecVisibility(), Exec: &executable.ExecExecutableType{ Params: params, Cmd: fmt.Sprintf("echo 'hello from %s'; %s", name, strings.Join(paramCmds, "; ")), @@ -213,13 +188,10 @@ func ExecWithParams(opts ...Option) *executable.Executable { func ExecWithLogMode(opts ...Option) *executable.Executable { name := "with-plaintext" - docstring := "The `logMode` field can be set to change the formatting of the executable's output logs.\n" + - "Valid values are `logfmt`, `text`, `json`, and `hidden`. The default value is determined by the user's configuration." e := &executable.Executable{ - Verb: "run", - Name: name, - Visibility: privateExecVisibility(), - Description: docstring, + Verb: "run", + Name: name, + Visibility: privateExecVisibility(), Exec: &executable.ExecExecutableType{ LogMode: tuikitIO.Text, Cmd: fmt.Sprintf( diff --git a/tools/builder/flowfile.go b/tests/utils/builder/flowfile.go similarity index 100% rename from tools/builder/flowfile.go rename to tests/utils/builder/flowfile.go diff --git a/tools/builder/opts.go b/tests/utils/builder/opts.go similarity index 100% rename from tools/builder/opts.go rename to tests/utils/builder/opts.go diff --git a/tools/builder/parallel.go b/tests/utils/builder/parallel.go similarity index 73% rename from tools/builder/parallel.go rename to tests/utils/builder/parallel.go index a1d61861..cf74d25b 100644 --- a/tools/builder/parallel.go +++ b/tests/utils/builder/parallel.go @@ -4,10 +4,6 @@ import ( "github.com/flowexec/flow/types/executable" ) -const ( - parallelBaseDesc = "Multiple executables can be run concurrently using a parallel executable." -) - func ParallelExecByRefConfig(opts ...Option) *executable.Executable { name := "parallel-config" e1 := SimpleExec(opts...) @@ -16,9 +12,6 @@ func ParallelExecByRefConfig(opts ...Option) *executable.Executable { Verb: "start", Name: name, Visibility: privateExecVisibility(), - Description: parallelBaseDesc + - "The `execs` field can be used to define the child executables with more options. " + - "This includes defining an executable inline, retries, arguments, and more.", Parallel: &executable.ParallelExecutableType{ Execs: []executable.ParallelRefConfig{ {Ref: e1.Ref()}, @@ -45,8 +38,6 @@ func ParallelExecWithExit(opts ...Option) *executable.Executable { Name: name, Aliases: []string{"parallel-exit"}, Visibility: privateExecVisibility(), - Description: parallelBaseDesc + - "The `failFast` option can be set to `true` to stop the flow if a sub-executable fails.", Parallel: &executable.ParallelExecutableType{ FailFast: &ff, Execs: executable.ParallelRefConfigList{{Ref: e1.Ref()}, {Ref: e2.Ref()}, {Ref: e3.Ref()}}, @@ -61,8 +52,6 @@ func ParallelExecWithExit(opts ...Option) *executable.Executable { func ParallelExecWithMaxThreads(opts ...Option) *executable.Executable { e := ParallelExecByRefConfig(opts...) - e.Description = parallelBaseDesc + - "\n\nThe `maxThreads` option can be set to limit the number of concurrent executions." e.Parallel.MaxThreads = 1 return e } diff --git a/tools/builder/request.go b/tests/utils/builder/request.go similarity index 61% rename from tools/builder/request.go rename to tests/utils/builder/request.go index 84189490..4106f487 100644 --- a/tools/builder/request.go +++ b/tests/utils/builder/request.go @@ -4,21 +4,12 @@ import ( "github.com/flowexec/flow/types/executable" ) -const ( - requestBaseDesc = "Request executables send HTTP requests with the specified request and response settings.\n" -) - func RequestExec(opts ...Option) *executable.Executable { name := "request" - docstring := requestBaseDesc + - "The `url` field is required and must be a valid URL. " + - "The `method` field is optional and defaults to `GET`.\n" + - "The `headers` field is optional and can be used to set request headers." e := &executable.Executable{ - Verb: "run", - Name: name, - Visibility: privateExecVisibility(), - Description: docstring, + Verb: "run", + Name: name, + Visibility: privateExecVisibility(), Request: &executable.RequestExecutableType{ URL: "https://httpbin.org/get", Method: "GET", @@ -37,13 +28,10 @@ func RequestExec(opts ...Option) *executable.Executable { func RequestExecWithBody(opts ...Option) *executable.Executable { name := "request-with-body" - docstring := requestBaseDesc + - "The `body` field is optional and can be used to send a request body." e := &executable.Executable{ - Verb: "run", - Name: name, - Visibility: privateExecVisibility(), - Description: docstring, + Verb: "run", + Name: name, + Visibility: privateExecVisibility(), Request: &executable.RequestExecutableType{ URL: "https://httpbin.org/post", Method: "POST", @@ -59,13 +47,10 @@ func RequestExecWithBody(opts ...Option) *executable.Executable { func RequestExecWithTransform(opts ...Option) *executable.Executable { name := "request-with-transform" - docstring := requestBaseDesc + - "The `transformResponse` field is optional and can be used to transform the response using an Expr expression." e := &executable.Executable{ - Verb: "run", - Name: name, - Visibility: privateExecVisibility(), - Description: docstring, + Verb: "run", + Name: name, + Visibility: privateExecVisibility(), Request: &executable.RequestExecutableType{ URL: "https://httpbin.org/get", TransformResponse: "status", @@ -81,13 +66,10 @@ func RequestExecWithTransform(opts ...Option) *executable.Executable { func RequestExecWithTimeout(opts ...Option) *executable.Executable { name := "request-with-timeout" - docstring := requestBaseDesc + - "The `timeout` field is optional and can be used to set the request timeout." e := &executable.Executable{ - Verb: "run", - Name: name, - Visibility: privateExecVisibility(), - Description: docstring, + Verb: "run", + Name: name, + Visibility: privateExecVisibility(), Request: &executable.RequestExecutableType{ URL: "https://httpbin.org/delay/3", Timeout: 1, @@ -102,14 +84,10 @@ func RequestExecWithTimeout(opts ...Option) *executable.Executable { func RequestExecWithValidatedStatus(opts ...Option) *executable.Executable { name := "request-with-validated-status" - docstring := requestBaseDesc + - "The `validStatusCodes` field is optional and can be used to specify the valid status codes. " + - "If the response status code is not in the list, the executable will fail." e := &executable.Executable{ - Verb: "run", - Name: name, - Visibility: privateExecVisibility(), - Description: docstring, + Verb: "run", + Name: name, + Visibility: privateExecVisibility(), Request: &executable.RequestExecutableType{ URL: "https://httpbin.org/status/400", ValidStatusCodes: []int{200}, diff --git a/tools/builder/serial.go b/tests/utils/builder/serial.go similarity index 76% rename from tools/builder/serial.go rename to tests/utils/builder/serial.go index 16eabc8a..8d513dfd 100644 --- a/tools/builder/serial.go +++ b/tests/utils/builder/serial.go @@ -4,10 +4,6 @@ import ( "github.com/flowexec/flow/types/executable" ) -const ( - serialBaseDesc = "Multiple executables can be run in sequence using a serial executable.\n" -) - func SerialExecByRefConfig(opts ...Option) *executable.Executable { name := "serial-config" e1 := SimpleExec(opts...) @@ -16,9 +12,6 @@ func SerialExecByRefConfig(opts ...Option) *executable.Executable { Verb: "start", Name: name, Visibility: privateExecVisibility(), - Description: serialBaseDesc + - "The `execs` field can be used to define the child executables with more options. " + - "This includes defining an executable inline, retries, arguments, and more.", Serial: &executable.SerialExecutableType{ Execs: []executable.SerialRefConfig{ {Ref: e1.Ref()}, @@ -45,8 +38,6 @@ func SerialExecWithExit(opts ...Option) *executable.Executable { Name: name, Aliases: []string{"serial-exit"}, Visibility: privateExecVisibility(), - Description: serialBaseDesc + - "The `failFast` option can be set to `true` to stop the executable if a sub-executable fails.", Serial: &executable.SerialExecutableType{ FailFast: &ff, Execs: []executable.SerialRefConfig{{Ref: e1.Ref()}, {Ref: e2.Ref()}, {Ref: e3.Ref()}}, diff --git a/tests/utils/context.go b/tests/utils/context.go index 79f7d661..8159795f 100644 --- a/tests/utils/context.go +++ b/tests/utils/context.go @@ -22,7 +22,7 @@ import ( "github.com/flowexec/flow/internal/logger" "github.com/flowexec/flow/internal/runner/mocks" "github.com/flowexec/flow/internal/services/store" - "github.com/flowexec/flow/tools/builder" + "github.com/flowexec/flow/tests/utils/builder" "github.com/flowexec/flow/types/config" "github.com/flowexec/flow/types/workspace" )