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

@@ -8,9 +8,9 @@ import (
"sort"
"testing"
"lol.mleku.dev/chk"
"git.mleku.dev/mleku/nostr/encoders/event"
"git.mleku.dev/mleku/nostr/encoders/event/examples"
"lol.mleku.dev/chk"
)
func TestGetSerialById(t *testing.T) {
@@ -64,23 +64,28 @@ func TestGetSerialById(t *testing.T) {
// Now process the sorted events
eventCount := 0
skippedCount := 0
var events []*event.E
for _, ev := range allEvents {
events = append(events, ev)
// Save the event to the database
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
}
events = append(events, ev)
eventCount++
}
t.Logf("Successfully saved %d events to the database", eventCount)
t.Logf("Successfully saved %d events to the database (skipped %d invalid events)", eventCount, skippedCount)
// Test GetSerialById with a known event ID
testEvent := events[3] // Using the same event as in QueryForIds test
if len(events) < 4 {
t.Fatalf("Need at least 4 saved events, got %d", len(events))
}
testEvent := events[3]
// Get the serial by ID
serial, err := db.GetSerialById(testEvent.ID)