Wire native pipeline run commands and invocation-wide overrides
This commit is contained in:
33
internal/cli/native_process_test.go
Normal file
33
internal/cli/native_process_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExecutableRunRoutesDeclareTheSameRequiredInputs(t *testing.T) {
|
||||
binary := filepath.Join(t.TempDir(), "notarius")
|
||||
build := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), "build", "-o", binary, "../../cmd/notarius")
|
||||
build.Env = append(os.Environ(), "GOWORK=off")
|
||||
if output, err := build.CombinedOutput(); err != nil {
|
||||
t.Fatalf("build executable: %v\n%s", err, output)
|
||||
}
|
||||
for _, route := range [][]string{{"run"}, {"pipeline", "run"}} {
|
||||
help := exec.Command(binary, append(append([]string(nil), route...), "--help")...)
|
||||
output, err := help.CombinedOutput()
|
||||
if err != nil || !bytes.Contains(output, []byte("pipeline-id")) || !bytes.Contains(output, []byte("--input-file")) {
|
||||
t.Fatalf("%v help: %v\n%s", route, err, output)
|
||||
}
|
||||
missingInput := exec.Command(binary, append(append([]string(nil), route...), "demo")...)
|
||||
output, err = missingInput.CombinedOutput()
|
||||
var exit *exec.ExitError
|
||||
if !errors.As(err, &exit) || exit.ExitCode() != 2 || !bytes.Contains(output, []byte("--input-file")) {
|
||||
t.Fatalf("%v missing input: %v\n%s", route, err, output)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user