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

Function AuditLog

coderd/database/dbgen/dbgen.go:50–77  ·  view source on GitHub ↗
(t testing.TB, db database.Store, seed database.AuditLog)

Source from the content-addressed store, hash-verified

48})
49
50func AuditLog(t testing.TB, db database.Store, seed database.AuditLog) database.AuditLog {
51 log, err := db.InsertAuditLog(genCtx, database.InsertAuditLogParams{
52 ID: takeFirst(seed.ID, uuid.New()),
53 Time: takeFirst(seed.Time, dbtime.Now()),
54 UserID: takeFirst(seed.UserID, uuid.New()),
55 // Default to the nil uuid. So by default audit logs are not org scoped.
56 OrganizationID: takeFirst(seed.OrganizationID),
57 Ip: pqtype.Inet{
58 IPNet: takeFirstIP(seed.Ip.IPNet, net.IPNet{}),
59 Valid: takeFirst(seed.Ip.Valid, false),
60 },
61 UserAgent: sql.NullString{
62 String: takeFirst(seed.UserAgent.String, ""),
63 Valid: takeFirst(seed.UserAgent.Valid, false),
64 },
65 ResourceType: takeFirst(seed.ResourceType, database.ResourceTypeOrganization),
66 ResourceID: takeFirst(seed.ResourceID, uuid.New()),
67 ResourceTarget: takeFirst(seed.ResourceTarget, uuid.NewString()),
68 Action: takeFirst(seed.Action, database.AuditActionCreate),
69 Diff: takeFirstSlice(seed.Diff, []byte("{}")),
70 StatusCode: takeFirst(seed.StatusCode, 200),
71 AdditionalFields: takeFirstSlice(seed.AdditionalFields, []byte("{}")),
72 RequestID: takeFirst(seed.RequestID, uuid.New()),
73 ResourceIcon: takeFirst(seed.ResourceIcon, ""),
74 })
75 require.NoError(t, err, "insert audit log")
76 return log
77}
78
79func Chat(t testing.TB, db database.Store, seed database.Chat) database.Chat {
80 t.Helper()

Callers 8

TestDeprecatedConnEventsFunction · 0.92
TestAuditLogDefaultLimitFunction · 0.92
TestAuditLogCountFunction · 0.92
TestAuthorizedAuditLogsFunction · 0.92
TestDeleteOldAuditLogsFunction · 0.92
TestGeneratorFunction · 0.92

Calls 6

NowFunction · 0.92
takeFirstIPFunction · 0.85
takeFirstSliceFunction · 0.85
takeFirstFunction · 0.70
InsertAuditLogMethod · 0.65
NewMethod · 0.65

Tested by 8

TestDeprecatedConnEventsFunction · 0.74
TestAuditLogDefaultLimitFunction · 0.74
TestAuditLogCountFunction · 0.74
TestAuthorizedAuditLogsFunction · 0.74
TestDeleteOldAuditLogsFunction · 0.74
TestGeneratorFunction · 0.74