mirror of
https://github.com/j3ssie/osmedeus.git
synced 2026-08-23 16:12:29 +02:00
- Add replayDBOperations to reinitialize databases from imported workspaces, with proper parameter resolution and pre-condition skipping - Implement ISO 8601 timestamp format for snapshots (2026-02-13T18-20-34Z) instead of Unix epoch - Add --include-heavy flag to include large fields (raw_response, screenshot, blob_content) in database queries - Fix asset table default columns (url, status_code, content_length, title) for better UX - Skip heavy initialization for lightweight commands (help, version, completion) to avoid ~50MB overhead - Optimize database function execution via lazy config initialization - Fix binary installation via Nix to copy already-installed binaries to binaries folder
60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
package utils
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestGetPutLargeBuffer(t *testing.T) {
|
|
buf := GetLargeBuffer()
|
|
if buf == nil {
|
|
t.Fatal("expected non-nil buffer")
|
|
return
|
|
}
|
|
if len(*buf) != LargeBufferSize {
|
|
t.Errorf("expected buffer size %d, got %d", LargeBufferSize, len(*buf))
|
|
}
|
|
|
|
// Write some data
|
|
(*buf)[0] = 'x'
|
|
|
|
// Return to pool
|
|
PutLargeBuffer(buf)
|
|
|
|
// Get another - might be same buffer
|
|
buf2 := GetLargeBuffer()
|
|
if len(*buf2) != LargeBufferSize {
|
|
t.Errorf("expected buffer size %d after reuse, got %d", LargeBufferSize, len(*buf2))
|
|
}
|
|
PutLargeBuffer(buf2)
|
|
}
|
|
|
|
func TestPutNilBuffer(t *testing.T) {
|
|
// Should not panic
|
|
PutLargeBuffer(nil)
|
|
}
|
|
|
|
func TestGetScannerBuffer(t *testing.T) {
|
|
initial, max := GetScannerBuffer()
|
|
if len(initial) != 64*1024 {
|
|
t.Errorf("expected initial size 64KB, got %d", len(initial))
|
|
}
|
|
if max != LargeBufferSize {
|
|
t.Errorf("expected max size %d, got %d", LargeBufferSize, max)
|
|
}
|
|
}
|
|
|
|
func BenchmarkBufferPool(b *testing.B) {
|
|
b.Run("pool", func(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
buf := GetLargeBuffer()
|
|
PutLargeBuffer(buf)
|
|
}
|
|
})
|
|
|
|
b.Run("alloc", func(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
_ = make([]byte, LargeBufferSize)
|
|
}
|
|
})
|
|
}
|