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

Function TestAuditLogDescription

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

Source from the content-addressed store, hash-verified

52}
53
54func TestAuditLogDescription(t *testing.T) {
55 t.Parallel()
56 testCases := []struct {
57 name string
58 alog database.GetAuditLogsOffsetRow
59 want string
60 }{
61 {
62 name: "mainline",
63 alog: database.GetAuditLogsOffsetRow{
64 AuditLog: database.AuditLog{
65 Action: database.AuditActionCreate,
66 StatusCode: 200,
67 ResourceType: database.ResourceTypeWorkspace,
68 },
69 },
70 want: "{user} created workspace {target}",
71 },
72 {
73 name: "unsuccessful",
74 alog: database.GetAuditLogsOffsetRow{
75 AuditLog: database.AuditLog{
76 Action: database.AuditActionCreate,
77 StatusCode: 400,
78 ResourceType: database.ResourceTypeWorkspace,
79 },
80 },
81 want: "{user} unsuccessfully attempted to create workspace {target}",
82 },
83 {
84 name: "login",
85 alog: database.GetAuditLogsOffsetRow{
86 AuditLog: database.AuditLog{
87 Action: database.AuditActionLogin,
88 StatusCode: 200,
89 ResourceType: database.ResourceTypeApiKey,
90 },
91 },
92 want: "{user} logged in",
93 },
94 {
95 name: "unsuccessful_login",
96 alog: database.GetAuditLogsOffsetRow{
97 AuditLog: database.AuditLog{
98 Action: database.AuditActionLogin,
99 StatusCode: 401,
100 ResourceType: database.ResourceTypeApiKey,
101 },
102 },
103 want: "{user} unsuccessfully attempted to login",
104 },
105 {
106 name: "gitsshkey",
107 alog: database.GetAuditLogsOffsetRow{
108 AuditLog: database.AuditLog{
109 Action: database.AuditActionDelete,
110 StatusCode: 200,
111 ResourceType: database.ResourceTypeGitSshKey,

Callers

nothing calls this directly

Calls 4

chatAuditLogRowFunction · 0.85
auditLogDescriptionFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected