Use require for Error and NoError

Assert keeps going after failure, but require immediately fails
the tests, making it easier to find the output related to the test
failure, rather than having to comb through a bunch of subsequent
assertion failures. For equality tests, we may or may not want to
continue, but for error checks we almost always want to immediately
fail the test. Exceptions can be changed as-needed.
This commit is contained in:
Karl Isenberg
2024-03-20 13:19:18 -07:00
parent a6ea3e2bb6
commit 43868688d5
53 changed files with 751 additions and 721 deletions

View File

@@ -9,7 +9,6 @@ import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"sigs.k8s.io/kustomize/api/konfig"
"sigs.k8s.io/kustomize/api/provider"
@@ -97,8 +96,8 @@ func TestUpdateResourceOptions(t *testing.T) {
require.NoError(t, err)
}
actual, err := UpdateResourceOptions(in)
assert.NoError(t, err)
assert.NoError(t, expected.ErrorIfNotEqualLists(actual))
require.NoError(t, err)
require.NoError(t, expected.ErrorIfNotEqualLists(actual))
}
func TestUpdateResourceOptionsWithInvalidHashAnnotationValues(t *testing.T) {