Files
nexus/internal/rawclient/history_test.go
T
Andy DixonandClaude Sonnet 5 1a380a0e99 Rebrand: Nexus Terminal → Alchementary Link
Renames the product across the codebase: Go module path, config/data
paths, keychain service name, export file extension, build tooling,
docs, and UI text. Sidebar brand mark now reads ">_ AlchementaryLink"
with "Alchementary" in the connection-group gold accent colour, and
the window title is "Alchementary Link".

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019T8bJS8BCtY5GeSG2HBj1n
2026-09-03 16:41:23 +01:00

52 lines
1.3 KiB
Go

package rawclient
import (
"bytes"
"testing"
"github.com/andydixon/link/internal/models"
)
func TestHistoryIsCappedByEntryCount(t *testing.T) {
client := NewClient(&models.Profile{})
for i := 0; i < maxHistoryEntries+25; i++ {
client.appendHistory(HistoryEntry{Direction: "recv", Data: []byte{byte(i)}})
}
history := client.GetHistory()
if len(history) != maxHistoryEntries {
t.Fatalf("history length = %d, want %d", len(history), maxHistoryEntries)
}
}
func TestHistoryIsCappedByBytes(t *testing.T) {
client := NewClient(&models.Profile{})
chunk := bytes.Repeat([]byte("a"), 1024)
for i := 0; i < (maxHistoryBytes/len(chunk))+10; i++ {
client.appendHistory(HistoryEntry{Direction: "recv", Data: chunk})
}
total := 0
for _, entry := range client.GetHistory() {
total += len(entry.Data)
}
if total > maxHistoryBytes {
t.Fatalf("history bytes = %d, want <= %d", total, maxHistoryBytes)
}
}
func TestGetHistoryReturnsDeepCopy(t *testing.T) {
client := NewClient(&models.Profile{})
client.appendHistory(HistoryEntry{Direction: "recv", Data: []byte("secret")})
history := client.GetHistory()
history[0].Data[0] = 'X'
again := client.GetHistory()
if string(again[0].Data) != "secret" {
t.Fatalf("history was mutated through returned slice: %q", string(again[0].Data))
}
}