Files
silo-server/internal/diagnostics/shortid_test.go
Quick104andClaude Fable 5 4fa84a661a feat(diagnostics): client diagnostics server foundation
Implements slice 1 of docs/design/2026-07-19-client-diagnostics.md: the
versioned contract (schemas, fixtures, Go validator), storage-validated
diagnostics.uploads_enabled gate, account-scoped status endpoint, hardened
streaming multipart ingest with quota reservation and a receiving/ready/
failed report state machine, S3 streaming puts, acting-admin report API
(list/detail/download/delete with audit events), and the retention +
orphan-reconciliation cleanup task.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XppCCycoaskCsW7ja1fZct
2026-07-20 11:13:52 -04:00

44 lines
1.2 KiB
Go

package diagnostics
import (
"errors"
"strings"
"testing"
)
func TestNewShortIDIsParseable(t *testing.T) {
id, err := NewShortID()
if err != nil {
t.Fatalf("NewShortID: %v", err)
}
if len(id) != len(shortIDPrefix)+shortIDPayloadLength {
t.Fatalf("length = %d, want %d", len(id), len(shortIDPrefix)+shortIDPayloadLength)
}
if !strings.HasPrefix(id, shortIDPrefix) {
t.Fatalf("id = %q, want %s prefix", id, shortIDPrefix)
}
if _, err := ParseShortID(id); err != nil {
t.Fatalf("ParseShortID(%q): %v", id, err)
}
}
func TestParseShortIDNormalizesCaseAndOptionalPrefix(t *testing.T) {
for _, raw := range []string{"abcdef123456", "silo-abcdef123456", " SILO-ABCDEF123456 "} {
got, err := ParseShortID(raw)
if err != nil {
t.Fatalf("ParseShortID(%q): %v", raw, err)
}
if got != "SILO-ABCDEF123456" {
t.Fatalf("ParseShortID(%q) = %q, want SILO-ABCDEF123456", raw, got)
}
}
}
func TestParseShortIDRejectsAmbiguousCharacters(t *testing.T) {
for _, raw := range []string{"ABCDEF12345I", "ABCDEF12345L", "ABCDEF12345O", "ABCDEF12345U"} {
if _, err := ParseShortID(raw); !errors.Is(err, ErrInvalidShortID) {
t.Fatalf("ParseShortID(%q) error = %v, want ErrInvalidShortID", raw, err)
}
}
}