Skip to content

Commit 8118da9

Browse files
committed
fixup! remove fakeAcker in favour of generated Acker mock
1 parent 882623b commit 8118da9

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

internal/pkg/agent/application/upgrade/upgrade_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ import (
3636
"github.com/elastic/elastic-agent/pkg/core/logger"
3737
"github.com/elastic/elastic-agent/pkg/core/logger/loggertest"
3838
agtversion "github.com/elastic/elastic-agent/pkg/version"
39-
mockack "github.com/elastic/elastic-agent/testing/mocks/internal_/pkg/fleetapi/acker"
40-
mocks "github.com/elastic/elastic-agent/testing/mocks/pkg/control/v2/client"
39+
ackermocks "github.com/elastic/elastic-agent/testing/mocks/internal_/pkg/fleetapi/acker"
40+
clientmocks "github.com/elastic/elastic-agent/testing/mocks/pkg/control/v2/client"
4141
)
4242

4343
func Test_CopyFile(t *testing.T) {
@@ -239,7 +239,7 @@ func TestIsInProgress(t *testing.T) {
239239
t.Run(name, func(t *testing.T) {
240240
// Expect client.State() call to be made only if no Upgrade Watcher PIDs
241241
// are returned (i.e. no Upgrade Watcher is found to be running).
242-
mc := mocks.NewClient(t)
242+
mc := clientmocks.NewClient(t)
243243
if test.watcherPIDsFetcher != nil {
244244
pids, _ := test.watcherPIDsFetcher()
245245
if len(pids) == 0 {
@@ -293,15 +293,15 @@ func TestUpgraderAckAction(t *testing.T) {
293293
require.Nil(t, u.AckAction(t.Context(), nil, action))
294294
})
295295
t.Run("AckAction with acker", func(t *testing.T) {
296-
mockAcker := &mockack.Acker{}
296+
mockAcker := ackermocks.NewAcker(t)
297297
mockAcker.EXPECT().Ack(mock.Anything, action).Return(nil)
298298
mockAcker.EXPECT().Commit(mock.Anything).Return(nil)
299299

300300
require.Nil(t, u.AckAction(t.Context(), mockAcker, action))
301301
})
302302

303303
t.Run("AckAction with acker - failing commit", func(t *testing.T) {
304-
mockAcker := &mockack.Acker{}
304+
mockAcker := ackermocks.NewAcker(t)
305305

306306
errCommit := errors.New("failed commit")
307307
mockAcker.EXPECT().Ack(mock.Anything, action).Return(nil)
@@ -311,12 +311,12 @@ func TestUpgraderAckAction(t *testing.T) {
311311
})
312312

313313
t.Run("AckAction with acker - failed ack", func(t *testing.T) {
314-
mockAcker := &mockack.Acker{}
314+
mockAcker := ackermocks.NewAcker(t)
315315

316316
errAck := errors.New("ack error")
317317
mockAcker.EXPECT().Ack(mock.Anything, action).Return(errAck)
318-
mockAcker.EXPECT().Commit(mock.Anything).Return(nil)
319-
318+
// no expectation on Commit() since it shouldn't be called after an error during Ack()
319+
320320
require.ErrorIs(t, u.AckAction(t.Context(), mockAcker, action), errAck)
321321
})
322322
}

0 commit comments

Comments
 (0)