@@ -20,6 +20,7 @@ import (
2020 "bufio"
2121 "bytes"
2222 "context"
23+ "errors"
2324 "flag"
2425 "fmt"
2526 "io"
@@ -33,7 +34,7 @@ import (
3334
3435 "github.com/google/go-cmp/cmp"
3536 "github.com/mattn/go-shellwords"
36- "k8s.io/apimachinery/pkg/api/errors"
37+ k8serrors "k8s.io/apimachinery/pkg/api/errors"
3738 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3839 k8syaml "k8s.io/apimachinery/pkg/util/yaml"
3940 "k8s.io/client-go/tools/clientcmd"
@@ -115,7 +116,7 @@ func (m *testEnvKubeManager) CreateObjects(clientObjects []*unstructured.Unstruc
115116 obj .SetResourceVersion (createObj .GetResourceVersion ())
116117 err = m .client .Status ().Update (context .Background (), obj )
117118 // Updating status of static objects results in not found error.
118- if err != nil && ! errors .IsNotFound (err ) {
119+ if err != nil && ! k8serrors .IsNotFound (err ) {
119120 return err
120121 }
121122 }
@@ -272,6 +273,15 @@ func assertError(expected string) assertFunc {
272273 }
273274}
274275
276+ func assertErrorIs (want error ) assertFunc {
277+ return func (_ string , got error ) error {
278+ if errors .Is (got , want ) {
279+ return nil
280+ }
281+ return fmt .Errorf ("Expected error '%v' but got '%v'" , want , got )
282+ }
283+ }
284+
275285// Expect the command to succeed with the expected test output.
276286func assertGoldenValue (expected string ) assertFunc {
277287 return assert (
0 commit comments