Add comprehensive tests for new policy fields and combinations
Some checks failed
Go / build-and-release (push) Has been cancelled

Introduce tests to validate functionality for new policy fields, including `max_expiry_duration`, `protected_required`, `identifier_regex`, and `follows_whitelist_admins`. Also, cover combinations of new and existing fields to ensure compatibility and precedence rules are correctly enforced.

bump to v0.31.2
This commit is contained in:
2025-12-01 18:21:38 +00:00
parent 2e42caee0e
commit 869006c4c3
27 changed files with 2726 additions and 85 deletions

View File

@@ -9,15 +9,15 @@ import (
"testing"
"time"
"lol.mleku.dev/chk"
"lol.mleku.dev/errorf"
"git.mleku.dev/mleku/nostr/interfaces/signer/p8k"
"git.mleku.dev/mleku/nostr/encoders/event"
"git.mleku.dev/mleku/nostr/encoders/event/examples"
"git.mleku.dev/mleku/nostr/encoders/hex"
"git.mleku.dev/mleku/nostr/encoders/kind"
"git.mleku.dev/mleku/nostr/encoders/tag"
"git.mleku.dev/mleku/nostr/encoders/timestamp"
"git.mleku.dev/mleku/nostr/interfaces/signer/p8k"
"lol.mleku.dev/chk"
"lol.mleku.dev/errorf"
)
// TestSaveEvents tests saving all events from examples.Cache to the database
@@ -69,6 +69,7 @@ func TestSaveEvents(t *testing.T) {
// Count the number of events processed
eventCount := 0
skippedCount := 0
var kc, vc int
now := time.Now()
// Process each event in chronological order
@@ -76,12 +77,15 @@ func TestSaveEvents(t *testing.T) {
// Save the event to the database
var k, v int
if _, err = db.SaveEvent(ctx, ev); err != nil {
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
// Skip events that fail validation (e.g., kind 3 without p tags)
skippedCount++
continue
}
kc += k
vc += v
eventCount++
}
_ = skippedCount // Used for logging below
// Check for scanner errors
if err = scanner.Err(); err != nil {