Address kyaml windows compatibility issues

This commit is contained in:
Phillip Wittrock
2020-05-19 09:24:22 -07:00
parent 765a4888df
commit f17cec0b3f
10 changed files with 70 additions and 33 deletions

View File

@@ -1,13 +1,19 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package testutil_test
package testutil
import (
"bytes"
"sigs.k8s.io/kustomize/kyaml/kio"
"sigs.k8s.io/kustomize/kyaml/yaml"
"testing"
goerrors "github.com/go-errors/errors"
"github.com/stretchr/testify/assert"
)
func UpdateYamlString(doc string, functions ...yaml.Filter) (string, error) {
@@ -34,3 +40,22 @@ func UpdateYamlBytes(b []byte, function ...yaml.Filter) ([]byte, error) {
}.Execute()
return out.Bytes(), err
}
func AssertErrorContains(t *testing.T, err error, value string, msg ...string) {
if !assert.Error(t, err, msg) {
t.FailNow()
}
if !assert.Contains(t, err.Error(), value, msg) {
t.FailNow()
}
}
func AssertNoError(t *testing.T, err error, msg ...string) {
if !assert.NoError(t, err, msg) {
gerr, ok := err.(*goerrors.Error)
if ok {
t.Fatal(string(gerr.Stack()))
}
t.FailNow()
}
}