@@ -11,7 +11,6 @@ import (
1111 "testing"
1212 "time"
1313
14- "github.com/benbjohnson/clock"
1514 "github.com/go-chi/chi/v5"
1615 "github.com/hashicorp/yamux"
1716 "github.com/stretchr/testify/require"
@@ -30,6 +29,7 @@ import (
3029 "github.com/coder/coder/v2/codersdk"
3130 "github.com/coder/coder/v2/codersdk/agentsdk"
3231 "github.com/coder/coder/v2/testutil"
32+ "github.com/coder/quartz"
3333)
3434
3535func TestReplicaSetEvents (t * testing.T ) {
@@ -43,7 +43,7 @@ func TestReplicaSetEvents(t *testing.T) {
4343 namespace := "test-namespace"
4444 client := fake .NewSimpleClientset ()
4545
46- cMock := clock .NewMock ()
46+ cMock := quartz .NewMock (t )
4747 reporter , err := newPodEventLogger (ctx , podEventLoggerOptions {
4848 client : client ,
4949 coderURL : agentURL ,
@@ -140,7 +140,7 @@ func TestPodEvents(t *testing.T) {
140140 namespace := "test-namespace"
141141 client := fake .NewSimpleClientset ()
142142
143- cMock := clock .NewMock ()
143+ cMock := quartz .NewMock (t )
144144 reporter , err := newPodEventLogger (ctx , podEventLoggerOptions {
145145 client : client ,
146146 coderURL : agentURL ,
@@ -284,7 +284,7 @@ func Test_logQueuer(t *testing.T) {
284284 api := newFakeAgentAPI (t )
285285 agentURL , err := url .Parse (api .server .URL )
286286 require .NoError (t , err )
287- clock := clock .NewMock ()
287+ clock := quartz .NewMock (t )
288288 ttl := time .Second
289289
290290 ch := make (chan agentLog )
@@ -300,7 +300,7 @@ func Test_logQueuer(t *testing.T) {
300300 },
301301 }
302302
303- ctx , cancel := context .WithCancel (context .Background ())
303+ ctx , cancel := context .WithTimeout (context .Background (), 10 * time . Second )
304304 defer cancel ()
305305 go lq .work (ctx )
306306
@@ -335,7 +335,7 @@ func Test_logQueuer(t *testing.T) {
335335 logs = testutil .RequireRecvCtx (ctx , t , api .logs )
336336 require .Len (t , logs , 1 )
337337
338- clock .Add ( 2 * ttl )
338+ clock .Advance ( ttl )
339339 // wait for the client to disconnect
340340 _ = testutil .RequireRecvCtx (ctx , t , api .disconnect )
341341 })
0 commit comments