New 🌊 wave for @helm

Commit 36f2d388

36f2d388e0c3Merged

Sviatoslav Dumchenko <[email protected]> · 2 years ago · 19 files · ~19 modified

Description

fix(tests): make mock errors traceable

Details

Commit
36f2d388e0c3
Parent
ca2feb9f5d2c

pkg/hooks/run_test.gomodifiedView file

@@ -19,6 +19,15 @@
1919 mock.Mock
2020 }
2121
22+func NewMockHook(t *testing.T) *MockHook {
23+ t.Helper()
24+
25+ c := &MockHook{}
26+ c.Mock.Test(t)
27+
28+ return c
29+}
30+
2231 func (m *MockHook) Run(_ context.Context) error {
2332 return m.Called().Error(0)
2433 }
@@ -43,7 +52,7 @@
4352 }
4453
4554 func (ts *LifecycleRunTestSuite) TestRunNoError() {
46- hook := &MockHook{}
55+ hook := NewMockHook(ts.T())
4756 hook.On("Run").Return(nil)
4857
4958 lifecycle := hooks.Lifecycle{PreBuild: []hooks.Hook{hook}}
@@ -55,7 +64,7 @@
5564 }
5665
5766 func (ts *LifecycleRunTestSuite) TestRunError() {
58- hook := &MockHook{}
67+ hook := NewMockHook(ts.T())
5968 errExpected := errors.New("test 123")
6069 hook.On("Run").Return(errExpected)
6170 hook.On("Log").Return(log.WithField("test", ts.T().Name()))