Skip to content

Commit 433e534

Browse files
authored
chore(tests): drop use of testify/mock.Mock.TestData (#1467)
Simplify tests in pkg/helm by replacing a use of testify/mock.Mock.TestData with just direct storage in the MockHelm object. Why? I'm a maintainer of github.com/stretchr/testify/mock and we are considering deprecating (and ultimately removing) the TestData method because it brings the single requirement of dependency github.com/stretchr/objx.Map. See stretchr/testify#1752
1 parent aa93a16 commit 433e534

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

pkg/helm/jsonnet_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const kubeVersion = "1.18.0"
1414

1515
type MockHelm struct {
1616
mock.Mock
17+
templateCommandArgs []string
1718
}
1819

1920
// fulfill the Helm interface
@@ -34,7 +35,7 @@ func (m *MockHelm) Template(name, chart string, opts TemplateOpts) (manifest.Lis
3435
// them
3536
execHelm := &ExecHelm{}
3637
cmdArgs := execHelm.templateCommandArgs(name, chart, opts)
37-
m.TestData().Set("templateCommandArgs", cmdArgs)
38+
m.templateCommandArgs = cmdArgs
3839

3940
return args.Get(0).(manifest.List), args.Error(1)
4041
}
@@ -88,7 +89,7 @@ func callNativeFunction(t *testing.T, expectedHelmTemplateOptions TemplateOpts,
8889

8990
helmMock.AssertExpectations(t)
9091

91-
return helmMock.TestData().Get("templateCommandArgs").StringSlice()
92+
return helmMock.templateCommandArgs
9293
}
9394

9495
// TestDefaultCommandineFlagsIncludeCrds tests that the includeCrds flag is set

0 commit comments

Comments
 (0)