MCPcopy Index your code
hub / github.com/coder/coder / TestAuditLogIsResourceDeleted

Function TestAuditLogIsResourceDeleted

coderd/audit_internal_test.go:21–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestAuditLogIsResourceDeleted(t *testing.T) {
22 t.Parallel()
23
24 for _, tc := range []struct {
25 name string
26 err error
27 wantDeleted bool
28 }{
29 {name: "AnError", err: assert.AnError, wantDeleted: false},
30 {name: "NotAuthorized", err: dbauthz.NotAuthorizedError{}, wantDeleted: false},
31 {name: "NoError", err: nil, wantDeleted: false},
32 {name: "NoRows", err: sql.ErrNoRows, wantDeleted: true},
33 } {
34 t.Run(tc.name, func(t *testing.T) {
35 t.Parallel()
36
37 ctrl := gomock.NewController(t)
38 db := dbmock.NewMockStore(ctrl)
39 chatID := uuid.New()
40 db.EXPECT().GetChatByID(gomock.Any(), chatID).Return(database.Chat{}, tc.err)
41
42 api := &API{
43 Options: &Options{Database: db, Logger: slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})},
44 }
45
46 deleted := api.auditLogIsResourceDeleted(context.Background(), database.GetAuditLogsOffsetRow{
47 AuditLog: database.AuditLog{ResourceType: database.ResourceTypeChat, ResourceID: chatID},
48 })
49 require.Equal(t, tc.wantDeleted, deleted)
50 })
51 }
52}
53
54func TestAuditLogDescription(t *testing.T) {
55 t.Parallel()

Callers

nothing calls this directly

Calls 7

EXPECTMethod · 0.95
NewMockStoreFunction · 0.92
RunMethod · 0.65
NewMethod · 0.65
GetChatByIDMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected