progressed events, filters.

This commit is contained in:
Jay
2025-10-21 17:25:11 -04:00
parent 2c893f9619
commit 580b2e4859
9 changed files with 1714 additions and 40 deletions

View File

@@ -5,6 +5,10 @@ import (
"testing"
)
func intPtr(i int) *int {
return &i
}
func expectOk(t *testing.T, err error) {
if err != nil {
t.Errorf("got error: %s", err.Error())
@@ -28,3 +32,63 @@ func expectEqualStrings(t *testing.T, got, want string) {
t.Errorf("got %s, want %s", got, want)
}
}
func expectEqualIntPointers(t *testing.T, got, want *int) {
if *got != *want {
t.Errorf("got %d, want %d", *got, *want)
}
}
func expectEqualStringSlices(t *testing.T, got, want []string) {
if len(got) != len(want) {
t.Errorf("length mismatch: got %d, want %d", len(got), len(want))
return
}
for i := range got {
if got[i] != want[i] {
t.Errorf("index %d: got %s, want %s", i, got[i], want[i])
}
}
}
func expectEqualIntSlices(t *testing.T, got, want []int) {
if len(got) != len(want) {
t.Errorf("length mismatch: got %d, want %d", len(got), len(want))
return
}
for i := range got {
if got[i] != want[i] {
t.Errorf("index %d: got %d, want %d", i, got[i], want[i])
}
}
}
func expectEqualEvents(t *testing.T, got, want Event) {
if got.ID != want.ID ||
got.PubKey != want.PubKey ||
got.CreatedAt != want.CreatedAt ||
got.Kind != want.Kind ||
got.Content != want.Content ||
got.Sig != want.Sig ||
!equalTags(got.Tags, want.Tags) {
t.Errorf("got %+v, want %+v", got, want)
}
}
func equalTags(a, b [][]string) bool {
if len(a) != len(b) {
return false
}
for i := range a {
if len(a[i]) != len(b[i]) {
return false
}
for j := range a[i] {
if a[i][j] != b[i][j] {
return false
}
}
}
return true
}