// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial // SPDX-FileCopyrightText: 2025-2026 Christian Galo package instance_test import ( "context" "testing" "git.coopcloud.tech/wiki-cafe/member-console/internal/instance" ) // TestStore_KindMismatch pins the registry's second guard: a key declared // as one shape is refused by the other shape's accessor, so a JSON object // is never decoded as a boolean nor a boolean overwritten by an object. // The guard answers before the store reaches the database, which is why // this test needs none. func TestStore_KindMismatch(t *testing.T) { store := instance.NewStore(nil) ctx := context.Background() if _, err := store.GetBool(ctx, instance.StripeEnvironmentCheck); err == nil { t.Error("GetBool on a JSON key returned no error") } if err := store.SetBool(ctx, instance.StripeEnvironmentCheck, true, ""); err == nil { t.Error("SetBool on a JSON key returned no error") } if _, _, err := store.GetJSON(ctx, instance.SetupBannerDismissed); err == nil { t.Error("GetJSON on a boolean key returned no error") } if err := store.SetJSON(ctx, instance.SetupBannerDismissed, struct{}{}, ""); err == nil { t.Error("SetJSON on a boolean key returned no error") } if _, _, err := store.GetJSON(ctx, instance.Key("not_a_real_setting")); err == nil { t.Error("GetJSON on an undeclared key returned no error") } if err := store.SetJSON(ctx, instance.Key("not_a_real_setting"), struct{}{}, ""); err == nil { t.Error("SetJSON on an undeclared key returned no error") } }