MCPcopy Create free account
hub / github.com/coder/coder / TestPurge

Function TestPurge

coderd/database/dbpurge/dbpurge_test.go:54–69  ·  view source on GitHub ↗

Ensures no goroutines leak. nolint:paralleltest // It uses LockIDDBPurge.

(t *testing.T)

Source from the content-addressed store, hash-verified

52//
53//nolint:paralleltest // It uses LockIDDBPurge.
54func TestPurge(t *testing.T) {
55 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
56 defer cancel()
57
58 // We want to make sure dbpurge is actually started so that this test is meaningful.
59 clk := quartz.NewMock(t)
60 done := awaitDoTick(ctx, t, clk)
61 mDB := dbmock.NewMockStore(gomock.NewController(t))
62 mDB.EXPECT().GetChatRetentionDays(gomock.Any()).Return(int32(0), nil).AnyTimes()
63 mDB.EXPECT().GetChatAutoArchiveDays(gomock.Any(), codersdk.DefaultChatAutoArchiveDays).Return(int32(0), nil).AnyTimes()
64 mDB.EXPECT().GetChatDebugRetentionDays(gomock.Any(), codersdk.DefaultChatDebugRetentionDays).Return(int32(0), nil).AnyTimes()
65 mDB.EXPECT().InTx(gomock.Any(), database.DefaultTXOptions().WithID("db_purge")).Return(nil).Times(2)
66 purger := dbpurge.New(context.Background(), testutil.Logger(t), mDB, &codersdk.DeploymentValues{}, prometheus.NewRegistry(), nopAuditorPtr(t), dbpurge.WithClock(clk))
67 <-done // wait for doTick() to run.
68 require.NoError(t, purger.Close())
69}
70
71//nolint:paralleltest // It uses LockIDDBPurge.
72func TestMetrics(t *testing.T) {

Callers

nothing calls this directly

Calls 14

EXPECTMethod · 0.95
NewMockStoreFunction · 0.92
DefaultTXOptionsFunction · 0.92
NewFunction · 0.92
LoggerFunction · 0.92
WithClockFunction · 0.92
awaitDoTickFunction · 0.85
nopAuditorPtrFunction · 0.85
GetChatRetentionDaysMethod · 0.65
InTxMethod · 0.65

Tested by

no test coverage detected