mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
add option to continue pipeline when the input is empty
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
package kio_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -75,3 +77,34 @@ func TestPipelineWithCallback(t *testing.T) {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContinueIfInputEmpty(t *testing.T) {
|
||||
actual := &bytes.Buffer{}
|
||||
output := ByteWriter{
|
||||
Sort: true,
|
||||
WrappingKind: ResourceListKind,
|
||||
WrappingAPIVersion: ResourceListAPIVersion,
|
||||
}
|
||||
output.Writer = actual
|
||||
|
||||
p := Pipeline{
|
||||
Outputs: []Writer{output},
|
||||
ContinueIfInputEmpty: true,
|
||||
}
|
||||
|
||||
err := p.Execute()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
expected := `
|
||||
apiVersion: config.kubernetes.io/v1alpha1
|
||||
kind: ResourceList
|
||||
items: []
|
||||
`
|
||||
|
||||
if !assert.Equal(t,
|
||||
strings.TrimSpace(expected), strings.TrimSpace(actual.String())) {
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user