MCPcopy Create free account
hub / github.com/astercloud/aster / TestInMemoryAuditLog_GetStatus

Function TestInMemoryAuditLog_GetStatus

pkg/security/audit_test.go:265–281  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

263}
264
265func TestInMemoryAuditLog_GetStatus(t *testing.T) {
266 auditLog := NewInMemoryAuditLog(nil)
267 defer func() { _ = auditLog.Close() }()
268
269 // 添加一些事件
270 _ = auditLog.LogEvent(AuditEvent{Type: AuditTypeUserLogin, UserID: "user1"})
271 _ = auditLog.LogEvent(AuditEvent{Type: AuditTypeUserLogout, UserID: "user2"})
272
273 status := auditLog.GetStatus()
274 if status == nil {
275 t.Fatal("expected status, got nil")
276 }
277
278 if status.TotalEvents != 2 {
279 t.Errorf("expected TotalEvents 2, got %d", status.TotalEvents)
280 }
281}
282
283func TestInMemoryAuditLog_Close(t *testing.T) {
284 auditLog := NewInMemoryAuditLog(nil)

Callers

nothing calls this directly

Calls 4

CloseMethod · 0.95
LogEventMethod · 0.95
GetStatusMethod · 0.95
NewInMemoryAuditLogFunction · 0.85

Tested by

no test coverage detected