Files
s41r4j-cybot/internal/telemetry/telemetry_test.go
T
s41r4j 0f03d49514
CI / contracts (push) Canceled after 0s
Website / deploy (push) Canceled after 0s
CI / test (macos-latest) (push) Canceled after 0s
CI / test (ubuntu-24.04) (push) Canceled after 0s
CI / test (ubuntu-24.04-arm) (push) Canceled after 0s
CI / test (windows-latest) (push) Canceled after 0s
CI / Compact real-tool fixtures (ubuntu-24.04) (push) Canceled after 0s
CI / Compact real-tool fixtures (ubuntu-24.04-arm) (push) Canceled after 0s
CI / Code analysis fixtures (ubuntu-24.04) (push) Canceled after 0s
CI / Code analysis fixtures (ubuntu-24.04-arm) (push) Canceled after 0s
CI / Web engine fixtures (ubuntu-24.04) (push) Canceled after 0s
CI / Web engine fixtures (ubuntu-24.04-arm) (push) Canceled after 0s
CI / Chromium operation fixtures (ubuntu-24.04) (push) Canceled after 0s
CI / Chromium operation fixtures (ubuntu-24.04-arm) (push) Canceled after 0s
CI / operation-readiness (push) Canceled after 0s
CI / Supply chain fixtures (ubuntu-24.04) (push) Canceled after 0s
CI / Supply chain fixtures (ubuntu-24.04-arm) (push) Canceled after 0s
Initial commit
2026-11-01 09:14:18 +05:30

26 lines
591 B
Go

package telemetry
import (
"context"
"github.com/s41r4j/cybot/pkg/schema"
"path/filepath"
"testing"
"time"
)
func TestAuditJSONLRoundTripAndLimit(t *testing.T) {
l := New(filepath.Join(t.TempDir(), "audit.jsonl"))
for i := 0; i < 3; i++ {
if err := l.Write(context.Background(), schema.AuditEvent{Timestamp: time.Unix(int64(i), 0).UTC(), Level: "info", Event: "test", Message: "safe"}); err != nil {
t.Fatal(err)
}
}
got, err := l.Read(2)
if err != nil {
t.Fatal(err)
}
if len(got) != 2 || got[0].Timestamp.Unix() != 1 {
t.Fatalf("unexpected events: %#v", got)
}
}