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

Function TestInMemoryAuditLog_GetEvent

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

Source from the content-addressed store, hash-verified

105}
106
107func TestInMemoryAuditLog_GetEvent(t *testing.T) {
108 auditLog := NewInMemoryAuditLog(nil)
109 defer func() { _ = auditLog.Close() }()
110
111 event := AuditEvent{
112 ID: "event1",
113 Type: AuditTypeUserLogin,
114 UserID: "user1",
115 Message: "User logged in",
116 }
117
118 _ = auditLog.LogEvent(event)
119
120 // 获取事件
121 retrieved, err := auditLog.GetEvent("event1")
122 if err != nil {
123 t.Fatalf("GetEvent failed: %v", err)
124 }
125
126 if retrieved.UserID != "user1" {
127 t.Errorf("expected UserID 'user1', got '%s'", retrieved.UserID)
128 }
129}
130
131func TestInMemoryAuditLog_GetEvent_NotFound(t *testing.T) {
132 auditLog := NewInMemoryAuditLog(nil)

Callers

nothing calls this directly

Calls 4

CloseMethod · 0.95
LogEventMethod · 0.95
GetEventMethod · 0.95
NewInMemoryAuditLogFunction · 0.85

Tested by

no test coverage detected