mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 05:06:51 +00:00
fix(GODT-2774): Add external context to telemetry tasks
This ensures they get cancelled if the parent context becomes invalid
This commit is contained in:
committed by
Romain LE JEUNE
parent
6579cdfc7f
commit
c4f80103b6
@ -18,6 +18,7 @@
|
||||
package telemetry_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -52,21 +53,21 @@ func TestHeartbeat_default_heartbeat(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
mock.EXPECT().IsTelemetryAvailable().Return(true)
|
||||
mock.EXPECT().IsTelemetryAvailable(context.Background()).Return(true)
|
||||
mock.EXPECT().GetLastHeartbeatSent().Return(time.Date(2022, 6, 4, 0, 0, 0, 0, time.UTC))
|
||||
mock.EXPECT().SendHeartbeat(&data).Return(true)
|
||||
mock.EXPECT().SendHeartbeat(context.Background(), &data).Return(true)
|
||||
mock.EXPECT().SetLastHeartbeatSent(gomock.Any()).Return(nil)
|
||||
|
||||
hb.TrySending()
|
||||
hb.TrySending(context.Background())
|
||||
})
|
||||
}
|
||||
|
||||
func TestHeartbeat_already_sent_heartbeat(t *testing.T) {
|
||||
withHeartbeat(t, 1143, 1025, "/tmp", "defaultKeychain", func(hb *telemetry.Heartbeat, mock *mocks.MockHeartbeatManager) {
|
||||
mock.EXPECT().IsTelemetryAvailable().Return(true)
|
||||
mock.EXPECT().IsTelemetryAvailable(context.Background()).Return(true)
|
||||
mock.EXPECT().GetLastHeartbeatSent().Return(time.Now().Truncate(24 * time.Hour))
|
||||
|
||||
hb.TrySending()
|
||||
hb.TrySending(context.Background())
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user