(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func 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 | |
| 54 | func TestAuditLogDescription(t *testing.T) { |
| 55 | t.Parallel() |
nothing calls this directly
no test coverage detected