@@ -11,7 +11,6 @@ import (
11
11
"testing"
12
12
"time"
13
13
14
- "github.com/benbjohnson/clock"
15
14
"github.com/go-chi/chi/v5"
16
15
"github.com/hashicorp/yamux"
17
16
"github.com/stretchr/testify/require"
@@ -30,6 +29,7 @@ import (
30
29
"github.com/coder/coder/v2/codersdk"
31
30
"github.com/coder/coder/v2/codersdk/agentsdk"
32
31
"github.com/coder/coder/v2/testutil"
32
+ "github.com/coder/quartz"
33
33
)
34
34
35
35
func TestReplicaSetEvents (t * testing.T ) {
@@ -43,7 +43,7 @@ func TestReplicaSetEvents(t *testing.T) {
43
43
namespace := "test-namespace"
44
44
client := fake .NewSimpleClientset ()
45
45
46
- cMock := clock .NewMock ()
46
+ cMock := quartz .NewMock (t )
47
47
reporter , err := newPodEventLogger (ctx , podEventLoggerOptions {
48
48
client : client ,
49
49
coderURL : agentURL ,
@@ -140,7 +140,7 @@ func TestPodEvents(t *testing.T) {
140
140
namespace := "test-namespace"
141
141
client := fake .NewSimpleClientset ()
142
142
143
- cMock := clock .NewMock ()
143
+ cMock := quartz .NewMock (t )
144
144
reporter , err := newPodEventLogger (ctx , podEventLoggerOptions {
145
145
client : client ,
146
146
coderURL : agentURL ,
@@ -284,7 +284,7 @@ func Test_logQueuer(t *testing.T) {
284
284
api := newFakeAgentAPI (t )
285
285
agentURL , err := url .Parse (api .server .URL )
286
286
require .NoError (t , err )
287
- clock := clock .NewMock ()
287
+ clock := quartz .NewMock (t )
288
288
ttl := time .Second
289
289
290
290
ch := make (chan agentLog )
@@ -300,7 +300,7 @@ func Test_logQueuer(t *testing.T) {
300
300
},
301
301
}
302
302
303
- ctx , cancel := context .WithCancel (context .Background ())
303
+ ctx , cancel := context .WithTimeout (context .Background (), 10 * time . Second )
304
304
defer cancel ()
305
305
go lq .work (ctx )
306
306
@@ -335,7 +335,7 @@ func Test_logQueuer(t *testing.T) {
335
335
logs = testutil .RequireRecvCtx (ctx , t , api .logs )
336
336
require .Len (t , logs , 1 )
337
337
338
- clock .Add ( 2 * ttl )
338
+ clock .Advance ( ttl )
339
339
// wait for the client to disconnect
340
340
_ = testutil .RequireRecvCtx (ctx , t , api .disconnect )
341
341
})
0 commit comments