forked from mtusi2026/mtusi2026lab6
feat: add bounded observability and verified SLO incident alerts
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package config
|
||||
|
||||
import "testing"
|
||||
|
||||
// TestPersistenceConfiguration validates independent environment configurations.
|
||||
func TestPersistenceConfiguration(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
database string
|
||||
shards string
|
||||
coordinator string
|
||||
ttl string
|
||||
valid bool
|
||||
}{
|
||||
{"defaults", "postgres://localhost/test", "shard0=localhost:6379", "", "3600", true},
|
||||
{"missing database", "", "shard0=localhost:6379", "", "3600", false},
|
||||
{"missing coordinator", "postgres://localhost/test", "shard1=localhost:6379", "shard0", "3600", false},
|
||||
{"duplicate shard", "postgres://localhost/test", "shard0=a,shard0=b", "", "3600", false},
|
||||
{"invalid topology", "postgres://localhost/test", "wrong", "", "3600", false},
|
||||
{"invalid ttl", "postgres://localhost/test", "shard0=a", "", "no", false},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Setenv("DATABASE_URL", tc.database)
|
||||
t.Setenv("VALKEY_SHARDS", tc.shards)
|
||||
t.Setenv("VALKEY_COORDINATOR", tc.coordinator)
|
||||
t.Setenv("SESSION_TTL_SECONDS", tc.ttl)
|
||||
_, err := NewPersistence()
|
||||
if (err == nil) != tc.valid {
|
||||
t.Fatalf("unexpected validation result: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user