Skip to content

Commit

Permalink
Adjust PodCommandExecutor and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
e-sumin committed Dec 1, 2023
1 parent bc06376 commit ed20ccd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/kube/pod_command_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (p *podCommandExecutor) Exec(ctx context.Context, command []string, stdin i
)

go func() {
_, _, err = p.pcep.ExecWithOptions(opts)
err = p.pcep.ExecWithOptions(opts)
close(cmdDone)
}()

Expand Down
4 changes: 2 additions & 2 deletions pkg/kube/pod_command_executor_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
// PodCommandExecutorProcessor is an interface wrapping kubernetes API invocation
// it is purposed to be replaced by fake implementation in tests
type PodCommandExecutorProcessor interface {
ExecWithOptions(opts ExecOptions) (string, string, error)
ExecWithOptions(opts ExecOptions) error
}

type podCommandExecutorProcessor struct {
Expand All @@ -30,6 +30,6 @@ type podCommandExecutorProcessor struct {

// ExecWithOptions executes a command in the specified pod and container,
// returning stdout, stderr and error.
func (p *podCommandExecutorProcessor) ExecWithOptions(opts ExecOptions) (string, string, error) {
func (p *podCommandExecutorProcessor) ExecWithOptions(opts ExecOptions) error {
return ExecWithOptions(p.cli, opts)
}
6 changes: 2 additions & 4 deletions pkg/kube/pod_command_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ type fakePodCommandExecutorProcessor struct {
inExecWithOptionsOpts *ExecOptions
execWithOptionsStdout string
execWithOptionsStderr string
execWithOptionsRet1 string
execWithOptionsRet2 string
execWithOptionsErr error

// Signal to `ExecWithOptions` to start "executing" command.
Expand All @@ -79,7 +77,7 @@ type fakePodCommandExecutorProcessor struct {
execWithOptionsSyncEnd testBarrier
}

func (fprp *fakePodCommandExecutorProcessor) ExecWithOptions(opts ExecOptions) (string, string, error) {
func (fprp *fakePodCommandExecutorProcessor) ExecWithOptions(opts ExecOptions) error {
fprp.inExecWithOptionsOpts = &opts
fprp.execWithOptionsSyncStart.SyncWithController()
if opts.Stdout != nil && len(fprp.execWithOptionsStdout) > 0 {
Expand All @@ -90,7 +88,7 @@ func (fprp *fakePodCommandExecutorProcessor) ExecWithOptions(opts ExecOptions) (
}
fprp.execWithOptionsSyncEnd.SyncWithController()

return fprp.execWithOptionsRet1, fprp.execWithOptionsRet2, fprp.execWithOptionsErr
return fprp.execWithOptionsErr
}

func (s *PodCommandExecutorTestSuite) TestPodRunnerExec(c *C) {
Expand Down

0 comments on commit ed20ccd

Please sign in to comment.