feat: complete SOP execution workflow

This commit is contained in:
Eric 1549169735@qq.com
2026-08-09 00:29:26 +08:00
parent e32025d2ca
commit c5ab886b70
63 changed files with 1229 additions and 215 deletions

View File

@@ -0,0 +1,34 @@
package audit
import (
"testing"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"go.uber.org/zap/zaptest/observer"
)
func TestLogBusinessEventIncludesRequiredFields(t *testing.T) {
core, logs := observer.New(zapcore.InfoLevel)
undo := zap.ReplaceGlobals(zap.New(core))
defer undo()
logBusinessEvent([]zap.Field{
zap.Uint64("tenant_id", 1),
zap.Uint64("user_id", 2),
zap.String("action", "publish"),
zap.String("resource", "sop"),
zap.Uint64("resource_id", 3),
})
entries := logs.All()
if len(entries) != 1 || entries[0].Message != "business event" {
t.Fatalf("entries = %+v, want one business event", entries)
}
fields := entries[0].ContextMap()
for _, key := range []string{"tenant_id", "user_id", "action", "resource", "resource_id"} {
if _, ok := fields[key]; !ok {
t.Fatalf("required field %q is missing from business event", key)
}
}
}