Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pkg/cmd/clustertask/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,7 @@ func Test_ClusterTask_Start_v1beta1(t *testing.T) {
input pipelinev1beta1test.Clients
inputStream io.Reader
wantError bool
hasPrefix bool
want string
goldenFile bool
}{
Expand Down Expand Up @@ -1479,7 +1480,8 @@ func Test_ClusterTask_Start_v1beta1(t *testing.T) {
input: seeds[4].pipelineClient,
inputStream: nil,
wantError: true,
want: "time: unknown unit d in duration 5d",
hasPrefix: true,
want: `time: unknown unit`,
},
{
name: "Dry run with PodTemplate",
Expand Down Expand Up @@ -1623,7 +1625,12 @@ func Test_ClusterTask_Start_v1beta1(t *testing.T) {
if err == nil {
t.Errorf("Error expected here")
}
test.AssertOutput(t, tp.want, err.Error())

if tp.hasPrefix {
test.AssertOutputPrefix(t, tp.want, err.Error())
} else {
test.AssertOutput(t, tp.want, err.Error())
}
} else {
if err != nil {
t.Errorf("Unexpected error")
Expand Down
11 changes: 9 additions & 2 deletions pkg/cmd/pipeline/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ func TestPipelineV1beta1Start_ExecuteCommand(t *testing.T) {
namespace string
input *test.Params
wantError bool
hasPrefix bool
want string
goldenFile bool
}{
Expand Down Expand Up @@ -1347,7 +1348,8 @@ func TestPipelineV1beta1Start_ExecuteCommand(t *testing.T) {
namespace: "",
input: c2,
wantError: true,
want: "time: unknown unit d in duration 5d",
hasPrefix: true,
want: `time: unknown unit`,
},
{
name: "Dry Run with PodTemplate",
Expand Down Expand Up @@ -1379,7 +1381,12 @@ func TestPipelineV1beta1Start_ExecuteCommand(t *testing.T) {
if err == nil {
t.Errorf("error expected here")
}
test.AssertOutput(t, tp.want, err.Error())

if tp.hasPrefix {
test.AssertOutputPrefix(t, tp.want, err.Error())
} else {
test.AssertOutput(t, tp.want, err.Error())
}
} else {
if err != nil {
t.Errorf("unexpected Error")
Expand Down
11 changes: 9 additions & 2 deletions pkg/cmd/task/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4358,6 +4358,7 @@ func TestTaskStart_ExecuteCommand_v1beta1(t *testing.T) {
dynamic dynamic.Interface
input pipelinev1beta1test.Clients
wantError bool
hasPrefix bool
want string
goldenFile bool
}{
Expand Down Expand Up @@ -4518,7 +4519,8 @@ func TestTaskStart_ExecuteCommand_v1beta1(t *testing.T) {
dynamic: dc,
input: cs,
wantError: true,
want: "time: unknown unit d in duration 5d",
hasPrefix: true,
want: `time: unknown unit`,
},
{
name: "Dry Run with output=json -f v1beta1",
Expand Down Expand Up @@ -4583,7 +4585,12 @@ func TestTaskStart_ExecuteCommand_v1beta1(t *testing.T) {
if err == nil {
t.Errorf("error expected here")
}
test.AssertOutput(t, tp.want, err.Error())

if tp.hasPrefix {
test.AssertOutputPrefix(t, tp.want, err.Error())
} else {
test.AssertOutput(t, tp.want, err.Error())
}
} else {
if err != nil {
t.Errorf("unexpected Error")
Expand Down
4 changes: 3 additions & 1 deletion pkg/formatted/color_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package formatted
import (
"bytes"
"html/template"
"strconv"

"testing"

Expand All @@ -39,7 +40,8 @@ func TestRainbowsColours(t *testing.T) {

rb = newRainbow()
for c := range palette {
rb.get(string(c))
a := strconv.Itoa(c)
rb.get(a)
}
assert.Equal(t, rb.counter.value, uint32(0)) // Looped back to 0
}
Expand Down
17 changes: 17 additions & 0 deletions pkg/test/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package test

import (
"strings"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -57,3 +58,19 @@ Actual
%s
`, diff, expected, actual)
}

func AssertOutputPrefix(t *testing.T, expected, actual string) {
t.Helper()

if !strings.HasPrefix(actual, expected) {
t.Errorf(`
Unexpected output:

Expected prefix
%s

Actual
%s
`, expected, actual)
}
}