Documentation
¶
Overview ¶
Package appstoretest provides a shared contract test suite for all AppRegistrationStore implementations. Each backend (inmem, fs, gorm) calls these tests with its own factory function. Mirrors keystoretest.
Package appstoretest provides a shared contract test suite that every AppRegistrationStore backend (inmem, fs, gorm) runs against its own factory to prove uniform behavior.
<!-- design:start --> This package is test-only. It owns the behavioral contract for admin.AppRegistrationStore: rather than each backend re-deriving its own tests, every implementation hands a Factory to RunAll and inherits the same suite. Centralizing the contract here means a new invariant added once is enforced across inmem, fs, and gorm simultaneously, and divergent backend behavior surfaces as a failing shared test instead of an undocumented gap. It deliberately does not construct stores itself — backends inject creation via Factory so the suite stays storage-agnostic.
ENTITIES ¶
Factory — function type a backend supplies that returns a fresh AppRegistrationStore per test, inverting construction so the suite never depends on a concrete backend.
RunAll — entry point running the full suite of contract subtests against one factory; the single call site keeps every backend's coverage in lock-step.
TestSaveAndGet — asserts SaveApp then GetApp returns the saved registration, the baseline read-after-write contract.
TestNotFound — asserts GetApp on a missing client_id returns admin.ErrAppNotFound, pinning the sentinel-error contract for misses.
TestDeleteApp — asserts DeleteApp removes a registration and a later GetApp returns ErrAppNotFound, confirming deletion is observable.
TestDeleteNonexistent — asserts deleting a missing client_id returns ErrAppNotFound, aligning delete-miss semantics with KeyStorage.DeleteKey.
TestOverwriteApp — asserts re-saving an existing client_id replaces stored metadata, locking down upsert semantics for SaveApp.
TestListApps — asserts ListApps returns every saved registration, verifying enumeration completeness independent of insertion order.
TestListAppsEmpty — asserts ListApps on a fresh store returns an empty slice rather than an error, so callers need not special-case empty.
TestPersistence — asserts a saved registration is visible to a subsequent read on the same handle, catching write-buffering bugs in persistent backends (FS, GORM); trivially true for InMem.
TestAllFieldsRoundTrip — asserts every AppRegistration field survives a SaveApp/GetApp round-trip, catching backend serialization gaps such as GORM failing to JSON-encode slice fields. <!-- design:end -->
Index ¶
- func RunAll(t *testing.T, factory Factory)
- func TestAllFieldsRoundTrip(t *testing.T, factory Factory)
- func TestDeleteApp(t *testing.T, factory Factory)
- func TestDeleteNonexistent(t *testing.T, factory Factory)
- func TestListApps(t *testing.T, factory Factory)
- func TestListAppsEmpty(t *testing.T, factory Factory)
- func TestNotFound(t *testing.T, factory Factory)
- func TestOverwriteApp(t *testing.T, factory Factory)
- func TestPersistence(t *testing.T, factory Factory)
- func TestSaveAndGet(t *testing.T, factory Factory)
- type Factory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunAll ¶
RunAll runs the complete AppRegistrationStore test suite against the provided factory.
func TestAllFieldsRoundTrip ¶
TestAllFieldsRoundTrip verifies that every field on AppRegistration survives a SaveApp/GetApp round-trip. Catches backend serialization bugs (e.g., GORM forgetting to JSON-encode slice fields).
func TestDeleteApp ¶
TestDeleteApp verifies that DeleteApp removes the registration and subsequent GetApp returns ErrAppNotFound.
func TestDeleteNonexistent ¶
TestDeleteNonexistent verifies that deleting a missing client_id returns ErrAppNotFound, matching KeyStorage.DeleteKey semantics.
func TestListApps ¶
TestListApps verifies that ListApps returns every saved registration.
func TestListAppsEmpty ¶
TestListAppsEmpty verifies that ListApps on a fresh store returns an empty slice (not an error).
func TestNotFound ¶
TestNotFound verifies that GetApp on a missing client_id returns ErrAppNotFound.
func TestOverwriteApp ¶
TestOverwriteApp verifies that SaveApp on an existing client_id replaces the stored registration with the new metadata.
func TestPersistence ¶
TestPersistence verifies that a saved registration is visible to subsequent reads from the same store handle. For persistent backends (FS, GORM) this catches write-buffering bugs; for InMem it is trivially true.
func TestSaveAndGet ¶
TestSaveAndGet verifies that SaveApp followed by GetApp returns the saved registration.