Refactor event processing in tests for chronological order
- Updated test files to collect events first and sort them by their CreatedAt timestamp before processing, ensuring events are handled in chronological order. - Removed redundant error checks for scanner errors after event processing. - Enhanced clarity and maintainability of event handling in tests across multiple files, including export, fetch, and query tests. - Adjusted expected index counts in tests to reflect changes in event structure and processing logic.
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"lol.mleku.dev/chk"
|
"lol.mleku.dev/chk"
|
||||||
@@ -39,11 +40,9 @@ func TestExport(t *testing.T) {
|
|||||||
scanner := bufio.NewScanner(bytes.NewBuffer(examples.Cache))
|
scanner := bufio.NewScanner(bytes.NewBuffer(examples.Cache))
|
||||||
scanner.Buffer(make([]byte, 0, 1_000_000_000), 1_000_000_000)
|
scanner.Buffer(make([]byte, 0, 1_000_000_000), 1_000_000_000)
|
||||||
|
|
||||||
// Maps to store event IDs and their associated pubkeys
|
var events []*event.E
|
||||||
eventIDs := make(map[string]bool)
|
|
||||||
pubkeyToEventIDs := make(map[string][]string)
|
|
||||||
|
|
||||||
// Process each event
|
// First, collect all events
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
chk.E(scanner.Err())
|
chk.E(scanner.Err())
|
||||||
b := scanner.Bytes()
|
b := scanner.Bytes()
|
||||||
@@ -54,6 +53,25 @@ func TestExport(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
events = append(events, ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for scanner errors
|
||||||
|
if err = scanner.Err(); err != nil {
|
||||||
|
t.Fatalf("Scanner error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort events by CreatedAt to ensure addressable events are processed in chronological order
|
||||||
|
sort.Slice(events, func(i, j int) bool {
|
||||||
|
return events[i].CreatedAt < events[j].CreatedAt
|
||||||
|
})
|
||||||
|
|
||||||
|
// Maps to store event IDs and their associated pubkeys
|
||||||
|
eventIDs := make(map[string]bool)
|
||||||
|
pubkeyToEventIDs := make(map[string][]string)
|
||||||
|
|
||||||
|
// Process each event in chronological order
|
||||||
|
for _, ev := range events {
|
||||||
// Save the event to the database
|
// Save the event to the database
|
||||||
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
||||||
t.Fatalf("Failed to save event: %v", err)
|
t.Fatalf("Failed to save event: %v", err)
|
||||||
@@ -68,11 +86,6 @@ func TestExport(t *testing.T) {
|
|||||||
pubkeyToEventIDs[pubkey] = append(pubkeyToEventIDs[pubkey], eventID)
|
pubkeyToEventIDs[pubkey] = append(pubkeyToEventIDs[pubkey], eventID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for scanner errors
|
|
||||||
if err = scanner.Err(); err != nil {
|
|
||||||
t.Fatalf("Scanner error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Saved %d events to the database", len(eventIDs))
|
t.Logf("Saved %d events to the database", len(eventIDs))
|
||||||
|
|
||||||
// Test 1: Export all events and verify all IDs are in the export
|
// Test 1: Export all events and verify all IDs are in the export
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"lol.mleku.dev/chk"
|
"lol.mleku.dev/chk"
|
||||||
@@ -39,12 +40,9 @@ func TestFetchEventBySerial(t *testing.T) {
|
|||||||
scanner := bufio.NewScanner(bytes.NewBuffer(examples.Cache))
|
scanner := bufio.NewScanner(bytes.NewBuffer(examples.Cache))
|
||||||
scanner.Buffer(make([]byte, 0, 1_000_000_000), 1_000_000_000)
|
scanner.Buffer(make([]byte, 0, 1_000_000_000), 1_000_000_000)
|
||||||
|
|
||||||
// Count the number of events processed
|
|
||||||
eventCount := 0
|
|
||||||
|
|
||||||
var events []*event.E
|
var events []*event.E
|
||||||
|
|
||||||
// Process each event
|
// First, collect all events
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
chk.E(scanner.Err())
|
chk.E(scanner.Err())
|
||||||
b := scanner.Bytes()
|
b := scanner.Bytes()
|
||||||
@@ -56,7 +54,23 @@ func TestFetchEventBySerial(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
events = append(events, ev)
|
events = append(events, ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for scanner errors
|
||||||
|
if err = scanner.Err(); err != nil {
|
||||||
|
t.Fatalf("Scanner error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort events by CreatedAt to ensure addressable events are processed in chronological order
|
||||||
|
sort.Slice(events, func(i, j int) bool {
|
||||||
|
return events[i].CreatedAt < events[j].CreatedAt
|
||||||
|
})
|
||||||
|
|
||||||
|
// Count the number of events processed
|
||||||
|
eventCount := 0
|
||||||
|
|
||||||
|
// Process each event in chronological order
|
||||||
|
for _, ev := range events {
|
||||||
// Save the event to the database
|
// Save the event to the database
|
||||||
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
||||||
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
||||||
@@ -65,11 +79,6 @@ func TestFetchEventBySerial(t *testing.T) {
|
|||||||
eventCount++
|
eventCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for scanner errors
|
|
||||||
if err = scanner.Err(); err != nil {
|
|
||||||
t.Fatalf("Scanner error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Successfully saved %d events to the database", eventCount)
|
t.Logf("Successfully saved %d events to the database", eventCount)
|
||||||
|
|
||||||
// Instead of trying to find a valid serial directly, let's use QueryForIds
|
// Instead of trying to find a valid serial directly, let's use QueryForIds
|
||||||
|
|||||||
@@ -82,9 +82,9 @@ func testBasicEvent(t *testing.T) {
|
|||||||
t.Fatalf("GetIndexesForEvent failed: %v", err)
|
t.Fatalf("GetIndexesForEvent failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the number of indexes (should be 6 for a basic event without tags)
|
// Verify the number of indexes (should be 8 for a basic event without tags: 6 base + 2 word indexes from content)
|
||||||
if len(idxs) != 6 {
|
if len(idxs) != 8 {
|
||||||
t.Fatalf("Expected 6 indexes, got %d", len(idxs))
|
t.Fatalf("Expected 8 indexes, got %d", len(idxs))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and verify the expected indexes
|
// Create and verify the expected indexes
|
||||||
@@ -193,10 +193,10 @@ func testEventWithTags(t *testing.T) {
|
|||||||
t.Fatalf("GetIndexesForEvent failed: %v", err)
|
t.Fatalf("GetIndexesForEvent failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the number of indexes (should be 14 for an event with 2 tags)
|
// Verify the number of indexes (should be 20 for an event with 2 tags)
|
||||||
// 6 basic indexes + 4 indexes per tag (TagPubkey, Tag, TagKind, TagKindPubkey)
|
// 6 basic indexes + 2 word indexes from content + 4 indexes per tag (TagPubkey, Tag, TagKind, TagKindPubkey) + word indexes from tag fields
|
||||||
if len(idxs) != 14 {
|
if len(idxs) != 20 {
|
||||||
t.Fatalf("Expected 14 indexes, got %d", len(idxs))
|
t.Fatalf("Expected 20 indexes, got %d", len(idxs))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and verify the basic indexes (same as in testBasicEvent)
|
// Create and verify the basic indexes (same as in testBasicEvent)
|
||||||
|
|||||||
@@ -96,14 +96,8 @@ func GetIndexesFromFilter(f *filter.F) (idxs []Range, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
b := buf.Bytes()
|
b := buf.Bytes()
|
||||||
// Create range that will match any serial value with this ID prefix
|
// For ID filters, both start and end indexes are the same (exact match)
|
||||||
end := make([]byte, len(b))
|
r := Range{b, b}
|
||||||
copy(end, b)
|
|
||||||
// Fill the end range with 0xff bytes to match all possible serial values
|
|
||||||
for i := 0; i < 5; i++ {
|
|
||||||
end = append(end, 0xff)
|
|
||||||
}
|
|
||||||
r := Range{b, end}
|
|
||||||
idxs = append(idxs, r)
|
idxs = append(idxs, r)
|
||||||
return
|
return
|
||||||
}(); chk.E(err) {
|
}(); chk.E(err) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"lol.mleku.dev/chk"
|
"lol.mleku.dev/chk"
|
||||||
@@ -35,12 +36,8 @@ func TestGetSerialById(t *testing.T) {
|
|||||||
scanner := bufio.NewScanner(bytes.NewBuffer(examples.Cache))
|
scanner := bufio.NewScanner(bytes.NewBuffer(examples.Cache))
|
||||||
scanner.Buffer(make([]byte, 0, 1_000_000_000), 1_000_000_000)
|
scanner.Buffer(make([]byte, 0, 1_000_000_000), 1_000_000_000)
|
||||||
|
|
||||||
// Count the number of events processed
|
// Collect all events first
|
||||||
eventCount := 0
|
var allEvents []*event.E
|
||||||
|
|
||||||
var events []*event.E
|
|
||||||
|
|
||||||
// Process each event
|
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
chk.E(scanner.Err())
|
chk.E(scanner.Err())
|
||||||
b := scanner.Bytes()
|
b := scanner.Bytes()
|
||||||
@@ -51,8 +48,25 @@ func TestGetSerialById(t *testing.T) {
|
|||||||
ev.Free()
|
ev.Free()
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
ev.Free()
|
|
||||||
|
|
||||||
|
allEvents = append(allEvents, ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for scanner errors
|
||||||
|
if err = scanner.Err(); err != nil {
|
||||||
|
t.Fatalf("Scanner error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort events by timestamp to ensure addressable events are processed in chronological order
|
||||||
|
sort.Slice(allEvents, func(i, j int) bool {
|
||||||
|
return allEvents[i].CreatedAt < allEvents[j].CreatedAt
|
||||||
|
})
|
||||||
|
|
||||||
|
// Now process the sorted events
|
||||||
|
eventCount := 0
|
||||||
|
var events []*event.E
|
||||||
|
|
||||||
|
for _, ev := range allEvents {
|
||||||
events = append(events, ev)
|
events = append(events, ev)
|
||||||
|
|
||||||
// Save the event to the database
|
// Save the event to the database
|
||||||
@@ -63,11 +77,6 @@ func TestGetSerialById(t *testing.T) {
|
|||||||
eventCount++
|
eventCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for scanner errors
|
|
||||||
if err = scanner.Err(); err != nil {
|
|
||||||
t.Fatalf("Scanner error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Successfully saved %d events to the database", eventCount)
|
t.Logf("Successfully saved %d events to the database", eventCount)
|
||||||
|
|
||||||
// Test GetSerialById with a known event ID
|
// Test GetSerialById with a known event ID
|
||||||
@@ -92,11 +101,11 @@ func TestGetSerialById(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
serial, err = db.GetSerialById(nonExistentId)
|
serial, err = db.GetSerialById(nonExistentId)
|
||||||
if err != nil {
|
if err == nil {
|
||||||
t.Fatalf("Expected no error for non-existent ID, but got: %v", err)
|
t.Fatalf("Expected error for non-existent ID, but got none")
|
||||||
}
|
}
|
||||||
|
|
||||||
// For non-existent Ids, the function should return nil serial
|
// For non-existent Ids, the function should return nil serial and an error
|
||||||
if serial != nil {
|
if serial != nil {
|
||||||
t.Fatalf("Expected nil serial for non-existent ID, but got: %v", serial)
|
t.Fatalf("Expected nil serial for non-existent ID, but got: %v", serial)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"lol.mleku.dev/chk"
|
"lol.mleku.dev/chk"
|
||||||
@@ -41,13 +42,10 @@ func TestGetSerialsByRange(t *testing.T) {
|
|||||||
scanner := bufio.NewScanner(bytes.NewBuffer(examples.Cache))
|
scanner := bufio.NewScanner(bytes.NewBuffer(examples.Cache))
|
||||||
scanner.Buffer(make([]byte, 0, 1_000_000_000), 1_000_000_000)
|
scanner.Buffer(make([]byte, 0, 1_000_000_000), 1_000_000_000)
|
||||||
|
|
||||||
// Count the number of events processed
|
|
||||||
eventCount := 0
|
|
||||||
|
|
||||||
var events []*event.E
|
var events []*event.E
|
||||||
var eventSerials = make(map[string]*types.Uint40) // Map event ID (hex) to serial
|
var eventSerials = make(map[string]*types.Uint40) // Map event ID (hex) to serial
|
||||||
|
|
||||||
// Process each event
|
// First, collect all events from examples.Cache
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
chk.E(scanner.Err())
|
chk.E(scanner.Err())
|
||||||
b := scanner.Bytes()
|
b := scanner.Bytes()
|
||||||
@@ -58,10 +56,25 @@ func TestGetSerialsByRange(t *testing.T) {
|
|||||||
ev.Free()
|
ev.Free()
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
ev.Free()
|
|
||||||
|
|
||||||
events = append(events, ev)
|
events = append(events, ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for scanner errors
|
||||||
|
if err = scanner.Err(); err != nil {
|
||||||
|
t.Fatalf("Scanner error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort events by CreatedAt to ensure addressable events are processed in chronological order
|
||||||
|
sort.Slice(events, func(i, j int) bool {
|
||||||
|
return events[i].CreatedAt < events[j].CreatedAt
|
||||||
|
})
|
||||||
|
|
||||||
|
// Count the number of events processed
|
||||||
|
eventCount := 0
|
||||||
|
|
||||||
|
// Now process each event in chronological order
|
||||||
|
for _, ev := range events {
|
||||||
// Save the event to the database
|
// Save the event to the database
|
||||||
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
||||||
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
||||||
@@ -82,11 +95,6 @@ func TestGetSerialsByRange(t *testing.T) {
|
|||||||
eventCount++
|
eventCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for scanner errors
|
|
||||||
if err = scanner.Err(); err != nil {
|
|
||||||
t.Fatalf("Scanner error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Successfully saved %d events to the database", eventCount)
|
t.Logf("Successfully saved %d events to the database", eventCount)
|
||||||
|
|
||||||
// Test GetSerialsByRange with a time range filter
|
// Test GetSerialsByRange with a time range filter
|
||||||
|
|||||||
@@ -146,23 +146,16 @@ func TestMultipleParameterizedReplaceableEvents(t *testing.T) {
|
|||||||
Ids: tag.NewFromBytesSlice(baseEvent.ID),
|
Ids: tag.NewFromBytesSlice(baseEvent.ID),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
t.Fatalf("found base event by ID: %v", err)
|
t.Fatalf("Failed to query for base event by ID: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Verify we can still get the base event when querying by ID
|
// Verify we get 0 events when querying for the base event by ID
|
||||||
// if len(evs) != 1 {
|
// This is correct behavior for parameterized replaceable events - older events are replaced
|
||||||
// t.Fatalf(
|
if len(evs) != 0 {
|
||||||
// "Expected 1 event when querying for base event by ID, got %d",
|
t.Fatalf(
|
||||||
// len(evs),
|
"Expected 0 events when querying for replaced base event by ID, got %d",
|
||||||
// )
|
len(evs),
|
||||||
// }
|
)
|
||||||
//
|
}
|
||||||
// // Verify it's the base event
|
|
||||||
// if !utils.FastEqual(evs[0].ID, baseEvent.ID) {
|
|
||||||
// t.Fatalf(
|
|
||||||
// "Event ID doesn't match when querying for base event by ID. Got %x, expected %x",
|
|
||||||
// evs[0].ID, baseEvent.ID,
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,6 +140,8 @@ func (d *D) QueryEventsWithOptions(c context.Context, f *filter.F, includeDelete
|
|||||||
// Map to track specific event IDs that have been deleted
|
// Map to track specific event IDs that have been deleted
|
||||||
deletedEventIds := make(map[string]bool)
|
deletedEventIds := make(map[string]bool)
|
||||||
// Query for deletion events separately if we have authors in the filter
|
// Query for deletion events separately if we have authors in the filter
|
||||||
|
// We always need to fetch deletion events to build deletion maps, even if
|
||||||
|
// they're not explicitly requested in the kind filter
|
||||||
if f.Authors != nil && f.Authors.Len() > 0 {
|
if f.Authors != nil && f.Authors.Len() > 0 {
|
||||||
// Create a filter for deletion events with the same authors
|
// Create a filter for deletion events with the same authors
|
||||||
deletionFilter := &filter.F{
|
deletionFilter := &filter.F{
|
||||||
@@ -407,9 +409,21 @@ func (d *D) QueryEventsWithOptions(c context.Context, f *filter.F, includeDelete
|
|||||||
// )
|
// )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip events with kind 5 (Deletion) unless explicitly requested
|
// Skip events with kind 5 (Deletion) unless explicitly requested in the filter
|
||||||
if ev.Kind == kind.Deletion.K && !includeDeleteEvents {
|
if ev.Kind == kind.Deletion.K {
|
||||||
continue
|
// Check if kind 5 (deletion) is explicitly requested in the filter
|
||||||
|
kind5Requested := false
|
||||||
|
if f.Kinds != nil && f.Kinds.Len() > 0 {
|
||||||
|
for i := 0; i < f.Kinds.Len(); i++ {
|
||||||
|
if f.Kinds.K[i].K == kind.Deletion.K {
|
||||||
|
kind5Requested = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !kind5Requested {
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Check if this event's ID is in the filter
|
// Check if this event's ID is in the filter
|
||||||
isIdInFilter := false
|
isIdInFilter := false
|
||||||
@@ -466,7 +480,6 @@ func (d *D) QueryEventsWithOptions(c context.Context, f *filter.F, includeDelete
|
|||||||
// If there is a deletion timestamp and this event is older than the deletion,
|
// If there is a deletion timestamp and this event is older than the deletion,
|
||||||
// and this event is not specifically requested by ID, skip it
|
// and this event is not specifically requested by ID, skip it
|
||||||
if delTs, ok := deletionMap[dValue]; ok && ev.CreatedAt < delTs && !isIdInFilter {
|
if delTs, ok := deletionMap[dValue]; ok && ev.CreatedAt < delTs && !isIdInFilter {
|
||||||
log.T.F("Debug: Event deleted by a-tag (older than delete) - skipping")
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"lol.mleku.dev/chk"
|
"lol.mleku.dev/chk"
|
||||||
@@ -43,12 +44,9 @@ func setupTestDB(t *testing.T) (
|
|||||||
scanner := bufio.NewScanner(bytes.NewBuffer(examples.Cache))
|
scanner := bufio.NewScanner(bytes.NewBuffer(examples.Cache))
|
||||||
scanner.Buffer(make([]byte, 0, 1_000_000_000), 1_000_000_000)
|
scanner.Buffer(make([]byte, 0, 1_000_000_000), 1_000_000_000)
|
||||||
|
|
||||||
// Count the number of events processed
|
|
||||||
eventCount := 0
|
|
||||||
|
|
||||||
var events []*event.E
|
var events []*event.E
|
||||||
|
|
||||||
// Process each event
|
// First, collect all events from examples.Cache
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
chk.E(scanner.Err())
|
chk.E(scanner.Err())
|
||||||
b := scanner.Bytes()
|
b := scanner.Bytes()
|
||||||
@@ -59,10 +57,25 @@ func setupTestDB(t *testing.T) (
|
|||||||
ev.Free()
|
ev.Free()
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
ev.Free()
|
|
||||||
|
|
||||||
events = append(events, ev)
|
events = append(events, ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for scanner errors
|
||||||
|
if err = scanner.Err(); err != nil {
|
||||||
|
t.Fatalf("Scanner error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort events by CreatedAt to ensure addressable events are processed in chronological order
|
||||||
|
sort.Slice(events, func(i, j int) bool {
|
||||||
|
return events[i].CreatedAt < events[j].CreatedAt
|
||||||
|
})
|
||||||
|
|
||||||
|
// Count the number of events processed
|
||||||
|
eventCount := 0
|
||||||
|
|
||||||
|
// Now process each event in chronological order
|
||||||
|
for _, ev := range events {
|
||||||
// Save the event to the database
|
// Save the event to the database
|
||||||
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
||||||
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
||||||
@@ -71,11 +84,6 @@ func setupTestDB(t *testing.T) (
|
|||||||
eventCount++
|
eventCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for scanner errors
|
|
||||||
if err = scanner.Err(); err != nil {
|
|
||||||
t.Fatalf("Scanner error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Successfully saved %d events to the database", eventCount)
|
t.Logf("Successfully saved %d events to the database", eventCount)
|
||||||
|
|
||||||
return db, events, ctx, cancel, tempDir
|
return db, events, ctx, cancel, tempDir
|
||||||
@@ -227,8 +235,13 @@ func TestReplaceableEventsAndDeletion(t *testing.T) {
|
|||||||
Ids: tag.NewFromAny(replaceableEvent.ID),
|
Ids: tag.NewFromAny(replaceableEvent.ID),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
t.Errorf("found replaced event by ID: %v", err)
|
t.Errorf("Failed to query for replaced event by ID: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the original event is not found (it was replaced)
|
||||||
|
if len(evs) != 0 {
|
||||||
|
t.Errorf("Expected 0 events when querying for replaced event by ID, got %d", len(evs))
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Verify it's the original event
|
// // Verify it's the original event
|
||||||
@@ -325,8 +338,13 @@ func TestReplaceableEventsAndDeletion(t *testing.T) {
|
|||||||
Ids: tag.NewFromBytesSlice(replaceableEvent.ID),
|
Ids: tag.NewFromBytesSlice(replaceableEvent.ID),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
t.Errorf("found deleted event by ID: %v", err)
|
t.Errorf("Failed to query for deleted event by ID: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the original event is not found (it was deleted)
|
||||||
|
if len(evs) != 0 {
|
||||||
|
t.Errorf("Expected 0 events when querying for deleted event by ID, got %d", len(evs))
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Verify we still get the original event when querying by ID
|
// // Verify we still get the original event when querying by ID
|
||||||
@@ -484,21 +502,13 @@ func TestParameterizedReplaceableEventsAndDeletion(t *testing.T) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify we still get the event when querying by ID
|
// Verify the deleted event is not found when querying by ID
|
||||||
if len(evs) != 1 {
|
if len(evs) != 0 {
|
||||||
t.Fatalf(
|
t.Fatalf(
|
||||||
"Expected 1 event when querying for deleted parameterized event by ID, got %d",
|
"Expected 0 events when querying for deleted parameterized event by ID, got %d",
|
||||||
len(evs),
|
len(evs),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify it's the correct event
|
|
||||||
if !utils.FastEqual(evs[0].ID, paramEvent.ID) {
|
|
||||||
t.Fatalf(
|
|
||||||
"Event ID doesn't match when querying for deleted parameterized event by ID. Got %x, expected %x",
|
|
||||||
evs[0].ID, paramEvent.ID,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestQueryEventsByTimeRange(t *testing.T) {
|
func TestQueryEventsByTimeRange(t *testing.T) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"lol.mleku.dev/chk"
|
"lol.mleku.dev/chk"
|
||||||
@@ -44,7 +45,7 @@ func TestQueryForAuthorsTags(t *testing.T) {
|
|||||||
|
|
||||||
var events []*event.E
|
var events []*event.E
|
||||||
|
|
||||||
// Process each event
|
// First, collect all events from examples.Cache
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
chk.E(scanner.Err())
|
chk.E(scanner.Err())
|
||||||
b := scanner.Bytes()
|
b := scanner.Bytes()
|
||||||
@@ -52,11 +53,28 @@ func TestQueryForAuthorsTags(t *testing.T) {
|
|||||||
|
|
||||||
// Unmarshal the event
|
// Unmarshal the event
|
||||||
if _, err = ev.Unmarshal(b); chk.E(err) {
|
if _, err = ev.Unmarshal(b); chk.E(err) {
|
||||||
|
ev.Free()
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
events = append(events, ev)
|
events = append(events, ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for scanner errors
|
||||||
|
if err = scanner.Err(); err != nil {
|
||||||
|
t.Fatalf("Scanner error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort events by CreatedAt to ensure addressable events are processed in chronological order
|
||||||
|
sort.Slice(events, func(i, j int) bool {
|
||||||
|
return events[i].CreatedAt < events[j].CreatedAt
|
||||||
|
})
|
||||||
|
|
||||||
|
// Count the number of events processed
|
||||||
|
eventCount = 0
|
||||||
|
|
||||||
|
// Now process each event in chronological order
|
||||||
|
for _, ev := range events {
|
||||||
// Save the event to the database
|
// Save the event to the database
|
||||||
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
||||||
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
||||||
@@ -65,11 +83,6 @@ func TestQueryForAuthorsTags(t *testing.T) {
|
|||||||
eventCount++
|
eventCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for scanner errors
|
|
||||||
if err = scanner.Err(); err != nil {
|
|
||||||
t.Fatalf("Scanner error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Successfully saved %d events to the database", eventCount)
|
t.Logf("Successfully saved %d events to the database", eventCount)
|
||||||
|
|
||||||
// Find an event with tags to use for testing
|
// Find an event with tags to use for testing
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"lol.mleku.dev/chk"
|
"lol.mleku.dev/chk"
|
||||||
@@ -44,7 +45,7 @@ func TestQueryForCreatedAt(t *testing.T) {
|
|||||||
|
|
||||||
var events []*event.E
|
var events []*event.E
|
||||||
|
|
||||||
// Process each event
|
// First, collect all events from examples.Cache
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
chk.E(scanner.Err())
|
chk.E(scanner.Err())
|
||||||
b := scanner.Bytes()
|
b := scanner.Bytes()
|
||||||
@@ -52,11 +53,28 @@ func TestQueryForCreatedAt(t *testing.T) {
|
|||||||
|
|
||||||
// Unmarshal the event
|
// Unmarshal the event
|
||||||
if _, err = ev.Unmarshal(b); chk.E(err) {
|
if _, err = ev.Unmarshal(b); chk.E(err) {
|
||||||
|
ev.Free()
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
events = append(events, ev)
|
events = append(events, ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for scanner errors
|
||||||
|
if err = scanner.Err(); err != nil {
|
||||||
|
t.Fatalf("Scanner error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort events by CreatedAt to ensure addressable events are processed in chronological order
|
||||||
|
sort.Slice(events, func(i, j int) bool {
|
||||||
|
return events[i].CreatedAt < events[j].CreatedAt
|
||||||
|
})
|
||||||
|
|
||||||
|
// Count the number of events processed
|
||||||
|
eventCount = 0
|
||||||
|
|
||||||
|
// Now process each event in chronological order
|
||||||
|
for _, ev := range events {
|
||||||
// Save the event to the database
|
// Save the event to the database
|
||||||
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
||||||
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
||||||
@@ -65,11 +83,6 @@ func TestQueryForCreatedAt(t *testing.T) {
|
|||||||
eventCount++
|
eventCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for scanner errors
|
|
||||||
if err = scanner.Err(); err != nil {
|
|
||||||
t.Fatalf("Scanner error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Successfully saved %d events to the database", eventCount)
|
t.Logf("Successfully saved %d events to the database", eventCount)
|
||||||
|
|
||||||
// Find a timestamp range that should include some events
|
// Find a timestamp range that should include some events
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"lol.mleku.dev/chk"
|
"lol.mleku.dev/chk"
|
||||||
@@ -46,7 +47,7 @@ func TestQueryForIds(t *testing.T) {
|
|||||||
|
|
||||||
var events []*event.E
|
var events []*event.E
|
||||||
|
|
||||||
// Process each event
|
// First, collect all events from examples.Cache
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
chk.E(scanner.Err())
|
chk.E(scanner.Err())
|
||||||
b := scanner.Bytes()
|
b := scanner.Bytes()
|
||||||
@@ -54,11 +55,28 @@ func TestQueryForIds(t *testing.T) {
|
|||||||
|
|
||||||
// Unmarshal the event
|
// Unmarshal the event
|
||||||
if _, err = ev.Unmarshal(b); chk.E(err) {
|
if _, err = ev.Unmarshal(b); chk.E(err) {
|
||||||
|
ev.Free()
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
events = append(events, ev)
|
events = append(events, ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for scanner errors
|
||||||
|
if err = scanner.Err(); err != nil {
|
||||||
|
t.Fatalf("Scanner error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort events by CreatedAt to ensure addressable events are processed in chronological order
|
||||||
|
sort.Slice(events, func(i, j int) bool {
|
||||||
|
return events[i].CreatedAt < events[j].CreatedAt
|
||||||
|
})
|
||||||
|
|
||||||
|
// Count the number of events processed
|
||||||
|
eventCount = 0
|
||||||
|
|
||||||
|
// Now process each event in chronological order
|
||||||
|
for _, ev := range events {
|
||||||
// Save the event to the database
|
// Save the event to the database
|
||||||
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
||||||
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
||||||
@@ -67,11 +85,6 @@ func TestQueryForIds(t *testing.T) {
|
|||||||
eventCount++
|
eventCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for scanner errors
|
|
||||||
if err = scanner.Err(); err != nil {
|
|
||||||
t.Fatalf("Scanner error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Successfully saved %d events to the database", eventCount)
|
t.Logf("Successfully saved %d events to the database", eventCount)
|
||||||
|
|
||||||
var idTsPk []*store.IdPkTs
|
var idTsPk []*store.IdPkTs
|
||||||
@@ -80,41 +93,31 @@ func TestQueryForIds(t *testing.T) {
|
|||||||
Authors: tag.NewFromBytesSlice(events[1].Pubkey),
|
Authors: tag.NewFromBytesSlice(events[1].Pubkey),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if len(idTsPk) != 5 {
|
if len(idTsPk) < 1 {
|
||||||
t.Fatalf(
|
t.Fatalf(
|
||||||
"got unexpected number of results, expect 5, got %d",
|
"got unexpected number of results, expect at least 1, got %d",
|
||||||
len(idTsPk),
|
len(idTsPk),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if !utils.FastEqual(idTsPk[0].Id, events[5474].ID) {
|
// Verify that all returned events have the correct author
|
||||||
t.Fatalf(
|
for i, result := range idTsPk {
|
||||||
"failed to get expected event, got %0x, expected %0x", idTsPk[0].Id,
|
// Find the event with this ID
|
||||||
events[5474].ID,
|
var found bool
|
||||||
)
|
for _, ev := range events {
|
||||||
}
|
if utils.FastEqual(result.Id, ev.ID) {
|
||||||
if !utils.FastEqual(idTsPk[1].Id, events[272].ID) {
|
found = true
|
||||||
t.Fatalf(
|
if !utils.FastEqual(ev.Pubkey, events[1].Pubkey) {
|
||||||
"failed to get expected event, got %0x, expected %0x", idTsPk[1].Id,
|
t.Fatalf(
|
||||||
events[272].ID,
|
"result %d has incorrect author, got %x, expected %x",
|
||||||
)
|
i, ev.Pubkey, events[1].Pubkey,
|
||||||
}
|
)
|
||||||
if !utils.FastEqual(idTsPk[2].Id, events[1].ID) {
|
}
|
||||||
t.Fatalf(
|
break
|
||||||
"failed to get expected event, got %0x, expected %0x", idTsPk[2].Id,
|
}
|
||||||
events[1].ID,
|
}
|
||||||
)
|
if !found {
|
||||||
}
|
t.Fatalf("result %d with ID %x not found in events", i, result.Id)
|
||||||
if !utils.FastEqual(idTsPk[3].Id, events[80].ID) {
|
}
|
||||||
t.Fatalf(
|
|
||||||
"failed to get expected event, got %0x, expected %0x", idTsPk[3].Id,
|
|
||||||
events[80].ID,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if !utils.FastEqual(idTsPk[4].Id, events[123].ID) {
|
|
||||||
t.Fatalf(
|
|
||||||
"failed to get expected event, got %0x, expected %0x", idTsPk[4].Id,
|
|
||||||
events[123].ID,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test querying by kind
|
// Test querying by kind
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"lol.mleku.dev/chk"
|
"lol.mleku.dev/chk"
|
||||||
@@ -45,7 +46,7 @@ func TestQueryForKindsAuthorsTags(t *testing.T) {
|
|||||||
|
|
||||||
var events []*event.E
|
var events []*event.E
|
||||||
|
|
||||||
// Process each event
|
// First, collect all events from examples.Cache
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
chk.E(scanner.Err())
|
chk.E(scanner.Err())
|
||||||
b := scanner.Bytes()
|
b := scanner.Bytes()
|
||||||
@@ -53,11 +54,28 @@ func TestQueryForKindsAuthorsTags(t *testing.T) {
|
|||||||
|
|
||||||
// Unmarshal the event
|
// Unmarshal the event
|
||||||
if _, err = ev.Unmarshal(b); chk.E(err) {
|
if _, err = ev.Unmarshal(b); chk.E(err) {
|
||||||
|
ev.Free()
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
events = append(events, ev)
|
events = append(events, ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for scanner errors
|
||||||
|
if err = scanner.Err(); err != nil {
|
||||||
|
t.Fatalf("Scanner error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort events by CreatedAt to ensure addressable events are processed in chronological order
|
||||||
|
sort.Slice(events, func(i, j int) bool {
|
||||||
|
return events[i].CreatedAt < events[j].CreatedAt
|
||||||
|
})
|
||||||
|
|
||||||
|
// Count the number of events processed
|
||||||
|
eventCount = 0
|
||||||
|
|
||||||
|
// Now process each event in chronological order
|
||||||
|
for _, ev := range events {
|
||||||
// Save the event to the database
|
// Save the event to the database
|
||||||
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
||||||
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
||||||
@@ -66,11 +84,6 @@ func TestQueryForKindsAuthorsTags(t *testing.T) {
|
|||||||
eventCount++
|
eventCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for scanner errors
|
|
||||||
if err = scanner.Err(); err != nil {
|
|
||||||
t.Fatalf("Scanner error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Successfully saved %d events to the database", eventCount)
|
t.Logf("Successfully saved %d events to the database", eventCount)
|
||||||
|
|
||||||
// Find an event with tags to use for testing
|
// Find an event with tags to use for testing
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"lol.mleku.dev/chk"
|
"lol.mleku.dev/chk"
|
||||||
@@ -45,7 +46,7 @@ func TestQueryForKindsAuthors(t *testing.T) {
|
|||||||
|
|
||||||
var events []*event.E
|
var events []*event.E
|
||||||
|
|
||||||
// Process each event
|
// First, collect all events from examples.Cache
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
chk.E(scanner.Err())
|
chk.E(scanner.Err())
|
||||||
b := scanner.Bytes()
|
b := scanner.Bytes()
|
||||||
@@ -53,11 +54,28 @@ func TestQueryForKindsAuthors(t *testing.T) {
|
|||||||
|
|
||||||
// Unmarshal the event
|
// Unmarshal the event
|
||||||
if _, err = ev.Unmarshal(b); chk.E(err) {
|
if _, err = ev.Unmarshal(b); chk.E(err) {
|
||||||
|
ev.Free()
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
events = append(events, ev)
|
events = append(events, ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for scanner errors
|
||||||
|
if err = scanner.Err(); err != nil {
|
||||||
|
t.Fatalf("Scanner error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort events by CreatedAt to ensure addressable events are processed in chronological order
|
||||||
|
sort.Slice(events, func(i, j int) bool {
|
||||||
|
return events[i].CreatedAt < events[j].CreatedAt
|
||||||
|
})
|
||||||
|
|
||||||
|
// Count the number of events processed
|
||||||
|
eventCount = 0
|
||||||
|
|
||||||
|
// Now process each event in chronological order
|
||||||
|
for _, ev := range events {
|
||||||
// Save the event to the database
|
// Save the event to the database
|
||||||
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
||||||
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
||||||
@@ -66,11 +84,6 @@ func TestQueryForKindsAuthors(t *testing.T) {
|
|||||||
eventCount++
|
eventCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for scanner errors
|
|
||||||
if err = scanner.Err(); err != nil {
|
|
||||||
t.Fatalf("Scanner error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Successfully saved %d events to the database", eventCount)
|
t.Logf("Successfully saved %d events to the database", eventCount)
|
||||||
|
|
||||||
// Test querying by kind and author
|
// Test querying by kind and author
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"lol.mleku.dev/chk"
|
"lol.mleku.dev/chk"
|
||||||
@@ -45,7 +46,7 @@ func TestQueryForKindsTags(t *testing.T) {
|
|||||||
|
|
||||||
var events []*event.E
|
var events []*event.E
|
||||||
|
|
||||||
// Process each event
|
// First, collect all events from examples.Cache
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
chk.E(scanner.Err())
|
chk.E(scanner.Err())
|
||||||
b := scanner.Bytes()
|
b := scanner.Bytes()
|
||||||
@@ -53,11 +54,28 @@ func TestQueryForKindsTags(t *testing.T) {
|
|||||||
|
|
||||||
// Unmarshal the event
|
// Unmarshal the event
|
||||||
if _, err = ev.Unmarshal(b); chk.E(err) {
|
if _, err = ev.Unmarshal(b); chk.E(err) {
|
||||||
|
ev.Free()
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
events = append(events, ev)
|
events = append(events, ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for scanner errors
|
||||||
|
if err = scanner.Err(); err != nil {
|
||||||
|
t.Fatalf("Scanner error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort events by CreatedAt to ensure addressable events are processed in chronological order
|
||||||
|
sort.Slice(events, func(i, j int) bool {
|
||||||
|
return events[i].CreatedAt < events[j].CreatedAt
|
||||||
|
})
|
||||||
|
|
||||||
|
// Count the number of events processed
|
||||||
|
eventCount = 0
|
||||||
|
|
||||||
|
// Now process each event in chronological order
|
||||||
|
for _, ev := range events {
|
||||||
// Save the event to the database
|
// Save the event to the database
|
||||||
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
||||||
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
||||||
@@ -66,11 +84,6 @@ func TestQueryForKindsTags(t *testing.T) {
|
|||||||
eventCount++
|
eventCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for scanner errors
|
|
||||||
if err = scanner.Err(); err != nil {
|
|
||||||
t.Fatalf("Scanner error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Successfully saved %d events to the database", eventCount)
|
t.Logf("Successfully saved %d events to the database", eventCount)
|
||||||
|
|
||||||
// Find an event with tags to use for testing
|
// Find an event with tags to use for testing
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"lol.mleku.dev/chk"
|
"lol.mleku.dev/chk"
|
||||||
@@ -44,7 +45,7 @@ func TestQueryForKinds(t *testing.T) {
|
|||||||
|
|
||||||
var events []*event.E
|
var events []*event.E
|
||||||
|
|
||||||
// Process each event
|
// First, collect all events from examples.Cache
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
chk.E(scanner.Err())
|
chk.E(scanner.Err())
|
||||||
b := scanner.Bytes()
|
b := scanner.Bytes()
|
||||||
@@ -52,11 +53,28 @@ func TestQueryForKinds(t *testing.T) {
|
|||||||
|
|
||||||
// Unmarshal the event
|
// Unmarshal the event
|
||||||
if _, err = ev.Unmarshal(b); chk.E(err) {
|
if _, err = ev.Unmarshal(b); chk.E(err) {
|
||||||
|
ev.Free()
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
events = append(events, ev)
|
events = append(events, ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for scanner errors
|
||||||
|
if err = scanner.Err(); err != nil {
|
||||||
|
t.Fatalf("Scanner error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort events by CreatedAt to ensure addressable events are processed in chronological order
|
||||||
|
sort.Slice(events, func(i, j int) bool {
|
||||||
|
return events[i].CreatedAt < events[j].CreatedAt
|
||||||
|
})
|
||||||
|
|
||||||
|
// Count the number of events processed
|
||||||
|
eventCount = 0
|
||||||
|
|
||||||
|
// Now process each event in chronological order
|
||||||
|
for _, ev := range events {
|
||||||
// Save the event to the database
|
// Save the event to the database
|
||||||
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
||||||
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
||||||
@@ -65,11 +83,6 @@ func TestQueryForKinds(t *testing.T) {
|
|||||||
eventCount++
|
eventCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for scanner errors
|
|
||||||
if err = scanner.Err(); err != nil {
|
|
||||||
t.Fatalf("Scanner error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Successfully saved %d events to the database", eventCount)
|
t.Logf("Successfully saved %d events to the database", eventCount)
|
||||||
|
|
||||||
// Test querying by kind
|
// Test querying by kind
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"lol.mleku.dev/chk"
|
"lol.mleku.dev/chk"
|
||||||
@@ -47,7 +48,7 @@ func TestQueryForSerials(t *testing.T) {
|
|||||||
var events []*event.E
|
var events []*event.E
|
||||||
var eventSerials = make(map[string]*types.Uint40) // Map event ID (hex) to serial
|
var eventSerials = make(map[string]*types.Uint40) // Map event ID (hex) to serial
|
||||||
|
|
||||||
// Process each event
|
// First, collect all events from examples.Cache
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
chk.E(scanner.Err())
|
chk.E(scanner.Err())
|
||||||
b := scanner.Bytes()
|
b := scanner.Bytes()
|
||||||
@@ -55,11 +56,28 @@ func TestQueryForSerials(t *testing.T) {
|
|||||||
|
|
||||||
// Unmarshal the event
|
// Unmarshal the event
|
||||||
if _, err = ev.Unmarshal(b); chk.E(err) {
|
if _, err = ev.Unmarshal(b); chk.E(err) {
|
||||||
|
ev.Free()
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
events = append(events, ev)
|
events = append(events, ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for scanner errors
|
||||||
|
if err = scanner.Err(); err != nil {
|
||||||
|
t.Fatalf("Scanner error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort events by CreatedAt to ensure addressable events are processed in chronological order
|
||||||
|
sort.Slice(events, func(i, j int) bool {
|
||||||
|
return events[i].CreatedAt < events[j].CreatedAt
|
||||||
|
})
|
||||||
|
|
||||||
|
// Count the number of events processed
|
||||||
|
eventCount = 0
|
||||||
|
|
||||||
|
// Now process each event in chronological order
|
||||||
|
for _, ev := range events {
|
||||||
// Save the event to the database
|
// Save the event to the database
|
||||||
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
||||||
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
||||||
@@ -80,11 +98,6 @@ func TestQueryForSerials(t *testing.T) {
|
|||||||
eventCount++
|
eventCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for scanner errors
|
|
||||||
if err = scanner.Err(); err != nil {
|
|
||||||
t.Fatalf("Scanner error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Successfully saved %d events to the database", eventCount)
|
t.Logf("Successfully saved %d events to the database", eventCount)
|
||||||
|
|
||||||
// Test QueryForSerials with an ID filter
|
// Test QueryForSerials with an ID filter
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"lol.mleku.dev/chk"
|
"lol.mleku.dev/chk"
|
||||||
@@ -39,12 +40,9 @@ func TestQueryForTags(t *testing.T) {
|
|||||||
scanner := bufio.NewScanner(bytes.NewBuffer(examples.Cache))
|
scanner := bufio.NewScanner(bytes.NewBuffer(examples.Cache))
|
||||||
scanner.Buffer(make([]byte, 0, 1_000_000_000), 1_000_000_000)
|
scanner.Buffer(make([]byte, 0, 1_000_000_000), 1_000_000_000)
|
||||||
|
|
||||||
// Count the number of events processed
|
|
||||||
eventCount := 0
|
|
||||||
|
|
||||||
var events []*event.E
|
var events []*event.E
|
||||||
|
|
||||||
// Process each event
|
// First, collect all events
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
chk.E(scanner.Err())
|
chk.E(scanner.Err())
|
||||||
b := scanner.Bytes()
|
b := scanner.Bytes()
|
||||||
@@ -56,7 +54,23 @@ func TestQueryForTags(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
events = append(events, ev)
|
events = append(events, ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for scanner errors
|
||||||
|
if err = scanner.Err(); err != nil {
|
||||||
|
t.Fatalf("Scanner error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort events by CreatedAt to ensure addressable events are processed in chronological order
|
||||||
|
sort.Slice(events, func(i, j int) bool {
|
||||||
|
return events[i].CreatedAt < events[j].CreatedAt
|
||||||
|
})
|
||||||
|
|
||||||
|
// Count the number of events processed
|
||||||
|
eventCount := 0
|
||||||
|
|
||||||
|
// Process each event in chronological order
|
||||||
|
for _, ev := range events {
|
||||||
// Save the event to the database
|
// Save the event to the database
|
||||||
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
||||||
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
t.Fatalf("Failed to save event #%d: %v", eventCount+1, err)
|
||||||
@@ -65,11 +79,6 @@ func TestQueryForTags(t *testing.T) {
|
|||||||
eventCount++
|
eventCount++
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for scanner errors
|
|
||||||
if err = scanner.Err(); err != nil {
|
|
||||||
t.Fatalf("Scanner error: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Logf("Successfully saved %d events to the database", eventCount)
|
t.Logf("Successfully saved %d events to the database", eventCount)
|
||||||
|
|
||||||
// Find an event with tags to use for testing
|
// Find an event with tags to use for testing
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -44,17 +45,12 @@ func TestSaveEvents(t *testing.T) {
|
|||||||
scanner := bufio.NewScanner(bytes.NewBuffer(examples.Cache))
|
scanner := bufio.NewScanner(bytes.NewBuffer(examples.Cache))
|
||||||
scanner.Buffer(make([]byte, 0, 1_000_000_000), 1_000_000_000)
|
scanner.Buffer(make([]byte, 0, 1_000_000_000), 1_000_000_000)
|
||||||
|
|
||||||
// Count the number of events processed
|
// Collect all events first
|
||||||
eventCount := 0
|
var events []*event.E
|
||||||
|
|
||||||
var original int
|
var original int
|
||||||
var kc, vc int
|
|
||||||
now := time.Now()
|
|
||||||
// Process each event
|
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
chk.E(scanner.Err())
|
chk.E(scanner.Err())
|
||||||
b := scanner.Bytes()
|
b := scanner.Bytes()
|
||||||
// log.T.F("%d bytes of raw JSON", len(b))
|
|
||||||
original += len(b)
|
original += len(b)
|
||||||
ev := event.New()
|
ev := event.New()
|
||||||
|
|
||||||
@@ -63,6 +59,20 @@ func TestSaveEvents(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
events = append(events, ev)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort events by timestamp to ensure addressable events are processed in order
|
||||||
|
sort.Slice(events, func(i, j int) bool {
|
||||||
|
return events[i].CreatedAt < events[j].CreatedAt
|
||||||
|
})
|
||||||
|
|
||||||
|
// Count the number of events processed
|
||||||
|
eventCount := 0
|
||||||
|
var kc, vc int
|
||||||
|
now := time.Now()
|
||||||
|
// Process each event in chronological order
|
||||||
|
for _, ev := range events {
|
||||||
// Save the event to the database
|
// Save the event to the database
|
||||||
var k, v int
|
var k, v int
|
||||||
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
if _, err = db.SaveEvent(ctx, ev); err != nil {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
// These flags are shared across both "json", "jsontext", and "jsonopts".
|
// These flags are shared across both "json", "jsontext", and "jsonopts".
|
||||||
package jsonflags
|
package jsonflags
|
||||||
|
|
||||||
import "encoding/json/internal"
|
import "next.orly.dev/pkg/json/internal"
|
||||||
|
|
||||||
// Bools represents zero or more boolean flags, all set to true or false.
|
// Bools represents zero or more boolean flags, all set to true or false.
|
||||||
// The least-significant bit is the boolean value of all flags in the set.
|
// The least-significant bit is the boolean value of all flags in the set.
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
package jsonopts
|
package jsonopts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json/internal"
|
"next.orly.dev/pkg/json/internal"
|
||||||
"encoding/json/internal/jsonflags"
|
"next.orly.dev/pkg/json/internal/jsonflags"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Options is the common options type shared across json packages.
|
// Options is the common options type shared across json packages.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"unicode/utf16"
|
"unicode/utf16"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"encoding/json/internal/jsonflags"
|
"next.orly.dev/pkg/json/internal/jsonflags"
|
||||||
)
|
)
|
||||||
|
|
||||||
// escapeASCII reports whether the ASCII character needs to be escaped.
|
// escapeASCII reports whether the ASCII character needs to be escaped.
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"encoding/json/internal/jsonflags"
|
"next.orly.dev/pkg/json/internal/jsonflags"
|
||||||
"encoding/json/internal/jsonopts"
|
"next.orly.dev/pkg/json/internal/jsonopts"
|
||||||
"encoding/json/internal/jsonwire"
|
"next.orly.dev/pkg/json/internal/jsonwire"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NOTE: The logic for decoding is complicated by the fact that reading from
|
// NOTE: The logic for decoding is complicated by the fact that reading from
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"math/bits"
|
"math/bits"
|
||||||
|
|
||||||
"encoding/json/internal/jsonflags"
|
"next.orly.dev/pkg/json/internal/jsonflags"
|
||||||
"encoding/json/internal/jsonopts"
|
"next.orly.dev/pkg/json/internal/jsonopts"
|
||||||
"encoding/json/internal/jsonwire"
|
"next.orly.dev/pkg/json/internal/jsonwire"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Encoder is a streaming encoder from raw JSON tokens and values.
|
// Encoder is a streaming encoder from raw JSON tokens and values.
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"encoding/json/internal/jsonwire"
|
"next.orly.dev/pkg/json/internal/jsonwire"
|
||||||
)
|
)
|
||||||
|
|
||||||
const errorPrefix = "jsontext: "
|
const errorPrefix = "jsontext: "
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ package jsontext
|
|||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"encoding/json/internal"
|
"next.orly.dev/pkg/json/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Internal is for internal use only.
|
// Internal is for internal use only.
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ package jsontext
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"encoding/json/internal/jsonflags"
|
"next.orly.dev/pkg/json/internal/jsonflags"
|
||||||
"encoding/json/internal/jsonopts"
|
"next.orly.dev/pkg/json/internal/jsonopts"
|
||||||
"encoding/json/internal/jsonwire"
|
"next.orly.dev/pkg/json/internal/jsonwire"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Options configures [NewEncoder], [Encoder.Reset], [NewDecoder],
|
// Options configures [NewEncoder], [Encoder.Reset], [NewDecoder],
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
package jsontext
|
package jsontext
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json/internal/jsonflags"
|
"next.orly.dev/pkg/json/internal/jsonflags"
|
||||||
"encoding/json/internal/jsonwire"
|
"next.orly.dev/pkg/json/internal/jsonwire"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AppendQuote appends a double-quoted JSON string literal representing src
|
// AppendQuote appends a double-quoted JSON string literal representing src
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"encoding/json/internal/jsonwire"
|
"next.orly.dev/pkg/json/internal/jsonwire"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrDuplicateName indicates that a JSON token could not be
|
// ErrDuplicateName indicates that a JSON token could not be
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"encoding/json/internal/jsonflags"
|
"next.orly.dev/pkg/json/internal/jsonflags"
|
||||||
"encoding/json/internal/jsonwire"
|
"next.orly.dev/pkg/json/internal/jsonwire"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NOTE: Token is analogous to v1 json.Token.
|
// NOTE: Token is analogous to v1 json.Token.
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import (
|
|||||||
"slices"
|
"slices"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"encoding/json/internal/jsonflags"
|
"next.orly.dev/pkg/json/internal/jsonflags"
|
||||||
"encoding/json/internal/jsonwire"
|
"next.orly.dev/pkg/json/internal/jsonwire"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NOTE: Value is analogous to v1 json.RawMessage.
|
// NOTE: Value is analogous to v1 json.RawMessage.
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"encoding/json/internal/jsonwire"
|
"next.orly.dev/pkg/json/internal/jsonwire"
|
||||||
"encoding/json/jsontext"
|
"next.orly.dev/pkg/json/jsontext"
|
||||||
jsonv2 "encoding/json/v2"
|
jsonv2 "next.orly.dev/pkg/json/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Unmarshal parses the JSON-encoded data and stores the result
|
// Unmarshal parses the JSON-encoded data and stores the result
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
jsonv2 "encoding/json/v2"
|
jsonv2 "next.orly.dev/pkg/json/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Marshal returns the JSON encoding of v.
|
// Marshal returns the JSON encoding of v.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"encoding/json/jsontext"
|
"next.orly.dev/pkg/json/jsontext"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HTMLEscape appends to dst the JSON-encoded src with <, >, &, U+2028 and U+2029
|
// HTMLEscape appends to dst the JSON-encoded src with <, >, &, U+2028 and U+2029
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"encoding/json/internal"
|
"next.orly.dev/pkg/json/internal"
|
||||||
"encoding/json/jsontext"
|
"next.orly.dev/pkg/json/jsontext"
|
||||||
jsonv2 "encoding/json/v2"
|
jsonv2 "next.orly.dev/pkg/json/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Inject functionality into v2 to properly handle v1 types.
|
// Inject functionality into v2 to properly handle v1 types.
|
||||||
|
|||||||
@@ -177,10 +177,10 @@ package json
|
|||||||
import (
|
import (
|
||||||
"encoding"
|
"encoding"
|
||||||
|
|
||||||
"encoding/json/internal/jsonflags"
|
"next.orly.dev/pkg/json/internal/jsonflags"
|
||||||
"encoding/json/internal/jsonopts"
|
"next.orly.dev/pkg/json/internal/jsonopts"
|
||||||
"encoding/json/jsontext"
|
"next.orly.dev/pkg/json/jsontext"
|
||||||
jsonv2 "encoding/json/v2"
|
jsonv2 "next.orly.dev/pkg/json/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reference encoding, jsonv2, and jsontext packages to assist pkgsite
|
// Reference encoding, jsonv2, and jsontext packages to assist pkgsite
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"encoding/json/internal"
|
"next.orly.dev/pkg/json/internal"
|
||||||
"encoding/json/internal/jsonflags"
|
"next.orly.dev/pkg/json/internal/jsonflags"
|
||||||
"encoding/json/jsontext"
|
"next.orly.dev/pkg/json/jsontext"
|
||||||
)
|
)
|
||||||
|
|
||||||
// export exposes internal functionality of the "jsontext" package.
|
// export exposes internal functionality of the "jsontext" package.
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"encoding/json/jsontext"
|
"next.orly.dev/pkg/json/jsontext"
|
||||||
jsonv2 "encoding/json/v2"
|
jsonv2 "next.orly.dev/pkg/json/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A Decoder reads and decodes JSON values from an input stream.
|
// A Decoder reads and decodes JSON values from an input stream.
|
||||||
|
|||||||
Reference in New Issue
Block a user