Skip to content

Commit

Permalink
test: test and lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hairyhum committed Feb 12, 2024
1 parent 76c51eb commit ad836c6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 0 additions & 4 deletions pkg/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,3 @@ func fPrintOutput(w io.Writer, key, value string) error {
fmt.Fprintln(w, PhaseOpString, outString)
return nil
}

const reStr = PhaseOpString + `(.*)$`

var logRE = regexp.MustCompile(reStr)
4 changes: 4 additions & 0 deletions pkg/output/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ import (
"context"
"io"
"strings"
"testing"

. "gopkg.in/check.v1"
)

// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { TestingT(t) }

type OutputSuite struct{}

var _ = Suite(&OutputSuite{})
Expand Down
22 changes: 11 additions & 11 deletions pkg/output/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,18 @@ func splitLines(ctx context.Context, r io.ReadCloser, f func(context.Context, []
if len(line) == 0 {
continue
}
if state.readingOutput {
switch {
case state.readingOutput:
if state, err = handleOutput(state, line, isPrefix, ctx, f); err != nil {
return err
}
} else {
if len(state.separatorSuffix) > 0 {
if state, err = handleSeparatorSuffix(state, line, isPrefix, ctx, f); err != nil {
return err
}
} else {
if state, err = handleLog(line, isPrefix, ctx, f); err != nil {
return err
}
case len(state.separatorSuffix) > 0:
if state, err = handleSeparatorSuffix(state, line, isPrefix, ctx, f); err != nil {
return err
}
default:
if state, err = handleLog(line, isPrefix, ctx, f); err != nil {
return err
}
}
}
Expand Down Expand Up @@ -109,7 +108,8 @@ func handleOutput(state scanState, line []byte, isPrefix bool, ctx context.Conte
return ReadPhaseOutputState(append(state.outputBuf, line...)), nil
} else {
// Reached the end of the line while reading phase output
outputContent := append(state.outputBuf, line...)
outputContent := state.outputBuf
outputContent = append(outputContent, line...)

if err := f(ctx, outputContent); err != nil {
return state, err
Expand Down

0 comments on commit ad836c6

Please sign in to comment.