Skip to content

Commit ab45fc7

Browse files
warberLaubi
authored andcommitted
chore: fail fast if something errors prior to running the test func
Signed-off-by: Bernd Warmuth <bernd.warmuth@dynatrace.com>
1 parent d9f558f commit ab45fc7

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

cmd/monaco/integrationtest/account/all_resources_integration_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/persistence/account/writer"
3030
"github.com/spf13/afero"
3131
"github.com/stretchr/testify/assert"
32+
"github.com/stretchr/testify/require"
3233
"net/http"
3334
"slices"
3435
"testing"
@@ -42,7 +43,7 @@ func TestDeployAndDelete_AllResources(t *testing.T) {
4243
cliDeployMZones.SetArgs([]string{"deploy", "testdata/all-resources/manifest-mzones.yaml"})
4344

4445
err := cliDeployMZones.Execute()
45-
assert.NoError(t, err)
46+
require.NoError(t, err)
4647

4748
RunAccountTestCase(t, "testdata/all-resources", "manifest-account.yaml", "am-all-resources", func(clients map[account.AccountInfo]*accounts.Client, o options) {
4849

cmd/monaco/integrationtest/account/runner.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/account"
2828
manifestloader "github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/manifest/loader"
2929
"github.com/spf13/afero"
30-
"github.com/stretchr/testify/assert"
30+
"github.com/stretchr/testify/require"
3131
"os"
3232
"strings"
3333
"testing"
@@ -56,9 +56,9 @@ func RunAccountTestCase(t *testing.T, path string, manifestFileName string, name
5656
// createAccountClientsFromManifest creates a map of accountInfo --> account client for a given manifest
5757
func createAccountClientsFromManifest(t *testing.T, fs afero.Fs, manifestFileName string) map[account.AccountInfo]*accounts.Client {
5858
m, errs := manifestloader.Load(&manifestloader.Context{Fs: fs, ManifestPath: manifestFileName, Opts: manifestloader.Options{RequireAccounts: true}})
59-
assert.NoError(t, errors.Join(errs...))
59+
require.NoError(t, errors.Join(errs...))
6060
accClients, err := dynatrace.CreateAccountClients(m.Accounts)
61-
assert.NoError(t, err)
61+
require.NoError(t, err)
6262
return accClients
6363
}
6464

@@ -67,13 +67,13 @@ func createAccountClientsFromManifest(t *testing.T, fs afero.Fs, manifestFileNam
6767
func randomizeYAMLResources(t *testing.T, fs afero.Fs, name string) string {
6868
randStr := integrationtest.GenerateTestSuffix(t, name)
6969
ff, err := files.FindYamlFiles(fs, ".")
70-
assert.NoError(t, err)
70+
require.NoError(t, err)
7171
for _, file := range ff {
7272
fileContent, err := afero.ReadFile(fs, file)
73-
assert.NoError(t, err)
73+
require.NoError(t, err)
7474
fileContentRandomized := randomizeFn(randStr)(string(fileContent))
7575
err = afero.WriteFile(fs, file, []byte(fileContentRandomized), 0644)
76-
assert.NoError(t, err)
76+
require.NoError(t, err)
7777
}
7878
return randStr
7979
}

0 commit comments

Comments
 (0)