chore: establish local platform baseline

This commit is contained in:
Codex Local
2026-08-26 06:41:54 +08:00
commit 29bdf4900f
575 changed files with 95644 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
package ratelimit
import "testing"
func TestIdentifierHashDoesNotExposeIdentifier(t *testing.T) {
identifier := "192.0.2.10"
first := IdentifierHash(identifier)
if len(first) != 32 || first == identifier || first != IdentifierHash(identifier) {
t.Fatalf("unexpected identifier hash: %s", first)
}
if first == IdentifierHash("192.0.2.11") {
t.Fatal("different identifiers should not share a hash")
}
}
func TestNewRejectsInvalidPolicy(t *testing.T) {
if _, err := New(nil, "", Policy{}); err == nil {
t.Fatal("invalid limiter configuration should fail")
}
}
func TestNewPoliciesRejectsInvalidScopedPolicy(t *testing.T) {
if _, err := NewPolicies(nil, "prefix", map[string]Policy{"device": {RatePerSecond: 1, Burst: 1}}); err == nil {
t.Fatal("nil Redis client should fail")
}
}