Skip to content

Commit 3b30d61

Browse files
committed
fallback to regular assert.Equal for smaller texts
1 parent 1e4172e commit 3b30d61

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

internal/testcli/golden.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/databricks/databricks-sdk-go"
1616
"github.com/databricks/databricks-sdk-go/service/iam"
1717
"github.com/elliotchance/orderedmap/v3"
18+
"github.com/stretchr/testify/assert"
1819
"github.com/stretchr/testify/require"
1920
)
2021

@@ -47,9 +48,15 @@ func RequireOutput(t testutil.TestingT, ctx context.Context, args []string, expe
4748
out = ReplaceOutput(t, ctx, out)
4849

4950
if out != expected {
50-
actual := fmt.Sprintf("Output from %v", args)
51-
diff := testutil.Diff(expectedFilename, actual, expected, out)
52-
t.Errorf("Diff:\n" + diff)
51+
if len(out) < 1000 && len(expected) < 1000 {
52+
// This shows full strings + diff which could be useful when debugging newlines
53+
assert.Equal(t, expected, out)
54+
} else {
55+
// only show diff for large texts
56+
actual := fmt.Sprintf("Output from %v", args)
57+
diff := testutil.Diff(expectedFilename, actual, expected, out)
58+
t.Errorf("Diff:\n" + diff)
59+
}
5360

5461
if os.Getenv("TESTS_OUTPUT") == "OVERWRITE" {
5562
WriteFile(t, ctx, filepath.Join(dir, expectedFilename), out)

0 commit comments

Comments
 (0)