Skip to content

Commit

Permalink
fallback to regular assert.Equal for smaller texts
Browse files Browse the repository at this point in the history
  • Loading branch information
denik committed Dec 18, 2024
1 parent 1e4172e commit 3b30d61
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/testcli/golden.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/service/iam"
"github.com/elliotchance/orderedmap/v3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

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

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

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

0 comments on commit 3b30d61

Please sign in to comment.