Foundation: config, schema/migrations, auth, stable IDs, metadata probing

This commit is contained in:
2026-08-22 23:29:16 -05:00
commit d4ea7a4ca9
40 changed files with 3874 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
package idgen
import (
"net/url"
"strings"
"testing"
)
func TestNewHasPrefix(t *testing.T) {
id := New("sg")
if !strings.HasPrefix(id, "sg_") {
t.Fatalf("New(%q) = %q, want prefix sg_", "sg", id)
}
}
func TestNewIsUnique(t *testing.T) {
seen := make(map[string]bool)
for i := 0; i < 1000; i++ {
id := New("sg")
if seen[id] {
t.Fatalf("duplicate ID generated: %s", id)
}
seen[id] = true
}
}
func TestNewIsURLSafe(t *testing.T) {
id := New("al")
if url.PathEscape(id) != id {
t.Fatalf("New() = %q is not URL-safe when path-escaped: %q", id, url.PathEscape(id))
}
}
func TestNewNoPrefix(t *testing.T) {
id := New("")
if strings.Contains(id, "_") {
t.Fatalf("New(\"\") = %q should not contain an underscore", id)
}
}