Function to set labels.

This commit is contained in:
Jeffrey Regan
2020-03-26 17:19:30 -07:00
committed by jregan
parent 85e9127071
commit 2be48ca96a
11 changed files with 371 additions and 189 deletions

View File

@@ -0,0 +1,30 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package filtertest_test
import (
"bytes"
"testing"
"github.com/stretchr/testify/assert"
"sigs.k8s.io/kustomize/kyaml/kio"
)
func RunFilter(t *testing.T, input string, f kio.Filter) string {
var out bytes.Buffer
rw := kio.ByteReadWriter{
Reader: bytes.NewBufferString(input),
Writer: &out,
}
err := kio.Pipeline{
Inputs: []kio.Reader{&rw},
Filters: []kio.Filter{f},
Outputs: []kio.Writer{&rw},
}.Execute()
if !assert.NoError(t, err) {
t.FailNow()
}
return out.String()
}