@@ -36,8 +36,8 @@ import (
36
36
"github.com/elastic/elastic-agent/pkg/core/logger"
37
37
"github.com/elastic/elastic-agent/pkg/core/logger/loggertest"
38
38
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"
41
41
)
42
42
43
43
func Test_CopyFile (t * testing.T ) {
@@ -239,7 +239,7 @@ func TestIsInProgress(t *testing.T) {
239
239
t .Run (name , func (t * testing.T ) {
240
240
// Expect client.State() call to be made only if no Upgrade Watcher PIDs
241
241
// are returned (i.e. no Upgrade Watcher is found to be running).
242
- mc := mocks .NewClient (t )
242
+ mc := clientmocks .NewClient (t )
243
243
if test .watcherPIDsFetcher != nil {
244
244
pids , _ := test .watcherPIDsFetcher ()
245
245
if len (pids ) == 0 {
@@ -293,15 +293,15 @@ func TestUpgraderAckAction(t *testing.T) {
293
293
require .Nil (t , u .AckAction (t .Context (), nil , action ))
294
294
})
295
295
t .Run ("AckAction with acker" , func (t * testing.T ) {
296
- mockAcker := & mockack. Acker {}
296
+ mockAcker := ackermocks . NewAcker ( t )
297
297
mockAcker .EXPECT ().Ack (mock .Anything , action ).Return (nil )
298
298
mockAcker .EXPECT ().Commit (mock .Anything ).Return (nil )
299
299
300
300
require .Nil (t , u .AckAction (t .Context (), mockAcker , action ))
301
301
})
302
302
303
303
t .Run ("AckAction with acker - failing commit" , func (t * testing.T ) {
304
- mockAcker := & mockack. Acker {}
304
+ mockAcker := ackermocks . NewAcker ( t )
305
305
306
306
errCommit := errors .New ("failed commit" )
307
307
mockAcker .EXPECT ().Ack (mock .Anything , action ).Return (nil )
@@ -311,12 +311,12 @@ func TestUpgraderAckAction(t *testing.T) {
311
311
})
312
312
313
313
t .Run ("AckAction with acker - failed ack" , func (t * testing.T ) {
314
- mockAcker := & mockack. Acker {}
314
+ mockAcker := ackermocks . NewAcker ( t )
315
315
316
316
errAck := errors .New ("ack error" )
317
317
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
+
320
320
require .ErrorIs (t , u .AckAction (t .Context (), mockAcker , action ), errAck )
321
321
})
322
322
}
0 commit comments