Skip to content

Commit

Permalink
ProjectLocation is always passed
Browse files Browse the repository at this point in the history
It is now a required argument for NewExecutor function
  • Loading branch information
mgencur committed Oct 12, 2023
1 parent b0c1be6 commit 3abb743
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 33 deletions.
19 changes: 0 additions & 19 deletions test/upgrade/shell/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package shell

import (
"bytes"
"errors"
"fmt"
"os"
"os/exec"
Expand All @@ -32,9 +31,6 @@ const (
executeMode = 0700
)

// ErrNoProjectLocation is returned if user didnt provided the project location.
var ErrNoProjectLocation = errors.New("project location isn't provided")

// NewExecutor creates a new executor.
func NewExecutor(t TestingT, loc ProjectLocation, opts ...Option) Executor {
config := &ExecutorConfig{
Expand All @@ -61,10 +57,6 @@ func testingTStreams(t TestingT) Streams {

// RunScript executes a shell script with args.
func (s *streamingExecutor) RunScript(script Script, args ...string) error {
err := validate(s.ExecutorConfig)
if err != nil {
return err
}
cnt := script.scriptContent(s.ProjectLocation, args)
return withTempScript(cnt, func(bin string) error {
return stream(bin, s.ExecutorConfig, script.Label)
Expand All @@ -73,10 +65,6 @@ func (s *streamingExecutor) RunScript(script Script, args ...string) error {

// RunFunction executes a shell function with args.
func (s *streamingExecutor) RunFunction(fn Function, args ...string) error {
err := validate(s.ExecutorConfig)
if err != nil {
return err
}
cnt := fn.scriptContent(s.ProjectLocation, args)
return withTempScript(cnt, func(bin string) error {
return stream(bin, s.ExecutorConfig, fn.Label)
Expand All @@ -87,13 +75,6 @@ type streamingExecutor struct {
ExecutorConfig
}

func validate(config ExecutorConfig) error {
if config.ProjectLocation == nil {
return ErrNoProjectLocation
}
return nil
}

func configureDefaultValues(config *ExecutorConfig) {
if config.LabelOut == "" {
config.LabelOut = defaultLabelOut
Expand Down
14 changes: 0 additions & 14 deletions test/upgrade/shell/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func TestNewExecutor(t *testing.T) {
helloWorldTestCase(t),
abortTestCase(t),
failExampleCase(t),
missingProjectLocationCase(),
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down Expand Up @@ -111,19 +110,6 @@ func failExampleCase(t *testing.T) testcase {
}
}

func missingProjectLocationCase() testcase {
return testcase{
"missing project location",
shell.ExecutorConfig{},
func(exec shell.Executor) error {
return exec.RunFunction(fn("id"))
},
wants{
failed: true,
},
}
}

type wants struct {
failed bool
outs []string
Expand Down

0 comments on commit 3abb743

Please sign in to comment.