feat(store): config table for instance-global app-config overrides
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
35
backend/internal/store/config_test.go
Normal file
35
backend/internal/store/config_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestConfigValues_EmptyThenUpsertOverwrites(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
values, err := db.ConfigValues(ctx)
|
||||
if err != nil {
|
||||
t.Fatalf("ConfigValues (empty): %v", err)
|
||||
}
|
||||
if len(values) != 0 {
|
||||
t.Fatalf("expected no overrides in a fresh DB, got %v", values)
|
||||
}
|
||||
|
||||
if err := db.SetConfigValue(ctx, "session.duration", "168"); err != nil {
|
||||
t.Fatalf("SetConfigValue: %v", err)
|
||||
}
|
||||
// Same key again: upsert must overwrite, not error or duplicate.
|
||||
if err := db.SetConfigValue(ctx, "session.duration", "24"); err != nil {
|
||||
t.Fatalf("SetConfigValue (overwrite): %v", err)
|
||||
}
|
||||
|
||||
values, err = db.ConfigValues(ctx)
|
||||
if err != nil {
|
||||
t.Fatalf("ConfigValues: %v", err)
|
||||
}
|
||||
if len(values) != 1 || values["session.duration"] != "24" {
|
||||
t.Fatalf("expected {session.duration: 24}, got %v", values)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user