Ensures no goroutines leak. nolint:paralleltest // It uses LockIDDBPurge.
(t *testing.T)
| 52 | // |
| 53 | //nolint:paralleltest // It uses LockIDDBPurge. |
| 54 | func 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. |
| 72 | func TestMetrics(t *testing.T) { |
nothing calls this directly
no test coverage detected