Add comprehensive tests for new policy fields and combinations
Some checks failed
Go / build-and-release (push) Has been cancelled
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:
@@ -8,12 +8,12 @@ import (
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"lol.mleku.dev/chk"
|
||||
"next.orly.dev/pkg/database/indexes/types"
|
||||
"git.mleku.dev/mleku/nostr/encoders/event"
|
||||
"git.mleku.dev/mleku/nostr/encoders/event/examples"
|
||||
"git.mleku.dev/mleku/nostr/encoders/filter"
|
||||
"git.mleku.dev/mleku/nostr/encoders/tag"
|
||||
"lol.mleku.dev/chk"
|
||||
"next.orly.dev/pkg/database/indexes/types"
|
||||
"next.orly.dev/pkg/utils"
|
||||
)
|
||||
|
||||
@@ -68,22 +68,32 @@ func TestFetchEventBySerial(t *testing.T) {
|
||||
|
||||
// Count the number of events processed
|
||||
eventCount := 0
|
||||
skippedCount := 0
|
||||
var savedEvents []*event.E
|
||||
|
||||
// Process each event in chronological order
|
||||
for _, ev := range events {
|
||||
// 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)
|
||||
// This can happen with real-world test data from examples.Cache
|
||||
skippedCount++
|
||||
continue
|
||||
}
|
||||
|
||||
savedEvents = append(savedEvents, 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)
|
||||
|
||||
// Instead of trying to find a valid serial directly, let's use QueryForIds
|
||||
// which is known to work from the other tests
|
||||
testEvent := events[3] // Using the same event as in other tests
|
||||
// Use the first successfully saved event (not original events which may include skipped ones)
|
||||
if len(savedEvents) < 4 {
|
||||
t.Fatalf("Need at least 4 saved events, got %d", len(savedEvents))
|
||||
}
|
||||
testEvent := savedEvents[3]
|
||||
|
||||
// Use QueryForIds to get the IdPkTs for this event
|
||||
var sers types.Uint40s
|
||||
|
||||
Reference in New Issue
Block a user