Skip to content

Commit 3c7ac16

Browse files
authored
Prefer using testify/assert over dynassert by default (#3310)
## Changes - Replace dynassert with testify/assert everywhere where testify/assert works. - Clean up dynassert proxy functions. We should use testify/assert directly. - Do not alias dynassert as assert. ## Why - testify/assert has more clear semantics. Its usage is also understood and fixed by linters. - It should be obvious to reader that this test uses equality with additional semantics (Mapping are compared unordered and locations are compared via Location() function), so explicit dynassert.Equal signals that. The custom equality should not mask standard equality. - By default we should be testing equality fully, with mapping order and full locations. Custom comparison in asserts should be an exception, not the default. ## Tests Existing tests. To ensure updated tests did not become flaky I ran `go test ./libs/dyn/... ./bundle/config/mutator/... -count=1000`
1 parent 4600f55 commit 3c7ac16

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+144
-270
lines changed

.golangci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ linters:
6565
- empty
6666
- len
6767
- equal-values
68+
- encoded-compare # Always replaces Equal() with JSONEq, but sometimes exact string match is wanted for JSON
6869
exclusions:
6970
generated: lax
7071
presets:

bundle/config/mutator/normalize_paths_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ import (
55
"path/filepath"
66
"testing"
77

8-
assert "github.com/databricks/cli/libs/dyn/dynassert"
9-
108
"github.com/databricks/cli/bundle"
119
"github.com/databricks/cli/bundle/config"
1210
"github.com/databricks/cli/bundle/config/resources"
1311
"github.com/databricks/cli/libs/dyn"
1412
"github.com/databricks/databricks-sdk-go/service/jobs"
13+
"github.com/stretchr/testify/assert"
1514
"github.com/stretchr/testify/require"
1615
)
1716

bundle/config/mutator/paths/app_paths_visitor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/databricks/cli/bundle/config"
77
"github.com/databricks/cli/bundle/config/resources"
88
"github.com/databricks/cli/libs/dyn"
9-
assert "github.com/databricks/cli/libs/dyn/dynassert"
9+
"github.com/stretchr/testify/assert"
1010
)
1111

1212
func TestAppPathsVisitor(t *testing.T) {

bundle/config/mutator/paths/dashboard_paths_visitor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/databricks/cli/bundle/config"
77
"github.com/databricks/cli/bundle/config/resources"
88
"github.com/databricks/cli/libs/dyn"
9-
assert "github.com/databricks/cli/libs/dyn/dynassert"
9+
"github.com/stretchr/testify/assert"
1010
)
1111

1212
func TestVisitDashboardPaths(t *testing.T) {

bundle/config/mutator/paths/job_paths_visitor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"github.com/databricks/cli/bundle/config"
77
"github.com/databricks/cli/bundle/config/resources"
88
"github.com/databricks/cli/libs/dyn"
9-
assert "github.com/databricks/cli/libs/dyn/dynassert"
109
"github.com/databricks/databricks-sdk-go/service/compute"
1110
"github.com/databricks/databricks-sdk-go/service/jobs"
11+
"github.com/stretchr/testify/assert"
1212
)
1313

1414
func TestVisitJobPaths(t *testing.T) {

bundle/config/mutator/paths/pipeline_paths_visitor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"github.com/databricks/cli/bundle/config"
77
"github.com/databricks/cli/bundle/config/resources"
88
"github.com/databricks/cli/libs/dyn"
9-
assert "github.com/databricks/cli/libs/dyn/dynassert"
109
"github.com/databricks/databricks-sdk-go/service/pipelines"
10+
"github.com/stretchr/testify/assert"
1111
)
1212

1313
func TestVisitPipelinePaths(t *testing.T) {

bundle/config/mutator/python/apply_python_output_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/databricks/cli/libs/dyn/merge"
99

1010
"github.com/databricks/cli/libs/dyn"
11-
assert "github.com/databricks/cli/libs/dyn/dynassert"
11+
"github.com/stretchr/testify/assert"
1212
)
1313

1414
type applyPythonOutputTestCase struct {

bundle/config/mutator/python/python_diagnostics_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
"github.com/databricks/cli/libs/diag"
88
"github.com/databricks/cli/libs/dyn"
9-
assert "github.com/databricks/cli/libs/dyn/dynassert"
9+
"github.com/stretchr/testify/assert"
1010
)
1111

1212
func TestConvertPythonLocation(t *testing.T) {

bundle/config/mutator/python/python_locations_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import (
66
"testing"
77

88
"github.com/databricks/cli/libs/diag"
9-
"github.com/stretchr/testify/require"
10-
119
"github.com/databricks/cli/libs/dyn"
12-
assert "github.com/databricks/cli/libs/dyn/dynassert"
10+
"github.com/databricks/cli/libs/dyn/dynassert"
11+
"github.com/stretchr/testify/assert"
12+
"github.com/stretchr/testify/require"
1313
)
1414

1515
func TestMergeLocations(t *testing.T) {
@@ -53,7 +53,7 @@ func TestMergeLocations(t *testing.T) {
5353
actual, err := mergePythonLocations(input, locations)
5454

5555
assert.NoError(t, err)
56-
assert.Equal(t, expected, actual)
56+
dynassert.Equal(t, expected, actual)
5757
}
5858

5959
func TestFindLocation(t *testing.T) {

bundle/config/mutator/python/python_mutator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020

2121
"github.com/databricks/cli/bundle"
2222
"github.com/databricks/cli/bundle/config"
23-
assert "github.com/databricks/cli/libs/dyn/dynassert"
2423
"github.com/databricks/cli/libs/process"
24+
"github.com/stretchr/testify/assert"
2525
)
2626

2727
func TestPythonMutator_Name_loadResources(t *testing.T) {

0 commit comments

Comments
 (0)