Improve test coverage by mocking exec output
This commit is contained in:
parent
a0df55a60c
commit
d87bdd451d
3
main.go
3
main.go
@ -186,10 +186,7 @@ func (job ContainerExecJob) Run() {
|
||||
|
||||
// Maybe print output
|
||||
if hj.Reader != nil {
|
||||
slog.Debugf("%s: Getting exec reader", job.name)
|
||||
for scanner.Scan() {
|
||||
slog.Debugf("%s: Getting exec line", job.name)
|
||||
|
||||
line := scanner.Text()
|
||||
if len(line) > 0 {
|
||||
slog.Infof("%s: Exec output: %s", job.name, line)
|
||||
|
@ -1,11 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
dockerTypes "github.com/docker/docker/api/types"
|
||||
@ -145,7 +147,9 @@ func (fakeClient *FakeDockerClient) ContainerInspect(ctx context.Context, contai
|
||||
}
|
||||
|
||||
func (fakeClient *FakeDockerClient) ContainerExecAttach(ctx context.Context, execID string, options container.ExecAttachOptions) (dockerTypes.HijackedResponse, error) {
|
||||
return dockerTypes.HijackedResponse{}, nil
|
||||
return dockerTypes.HijackedResponse{
|
||||
Reader: bufio.NewReader(strings.NewReader("Some output from our command")),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// NewFakeDockerClient creates an empty client
|
||||
|
Loading…
Reference in New Issue
Block a user