weiro/models/ids_test.go
Leon Mika e77cac2fd5 Started working on the frontend
- Added the new post frontend
- Hooked up publishing of posts to the site publisher
- Added an site exporter as a publishing target
2026-02-21 10:22:10 +11:00

35 lines
569 B
Go

package models
import (
"testing"
)
func TestNewNanoID(t *testing.T) {
id := NewNanoID()
if len(id) != 12 {
t.Errorf("Expected ID length of 12, got %d", len(id))
}
if id == "" {
t.Error("Expected non-empty ID")
}
}
func TestNewNanoID_Uniqueness(t *testing.T) {
ids := make(map[string]bool)
iterations := 1000
for i := 0; i < iterations; i++ {
id := NewNanoID()
if ids[id] {
t.Errorf("Duplicate ID generated: %s", id)
}
ids[id] = true
}
if len(ids) != iterations {
t.Errorf("Expected %d unique IDs, got %d", iterations, len(ids))
}
}