appstoretest

package
v0.0.84 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunAll

func RunAll(t *testing.T, factory Factory)

RunAll runs the complete AppRegistrationStore test suite against the provided factory.

func TestAllFieldsRoundTrip

func TestAllFieldsRoundTrip(t *testing.T, factory Factory)

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

func TestDeleteApp(t *testing.T, factory Factory)

TestDeleteApp verifies that DeleteApp removes the registration and subsequent GetApp returns ErrAppNotFound.

func TestDeleteNonexistent

func TestDeleteNonexistent(t *testing.T, factory Factory)

TestDeleteNonexistent verifies that deleting a missing client_id returns ErrAppNotFound, matching KeyStorage.DeleteKey semantics.

func TestListApps

func TestListApps(t *testing.T, factory Factory)

TestListApps verifies that ListApps returns every saved registration.

func TestListAppsEmpty

func TestListAppsEmpty(t *testing.T, factory Factory)

TestListAppsEmpty verifies that ListApps on a fresh store returns an empty slice (not an error).

func TestNotFound

func TestNotFound(t *testing.T, factory Factory)

TestNotFound verifies that GetApp on a missing client_id returns ErrAppNotFound.

func TestOverwriteApp

func TestOverwriteApp(t *testing.T, factory Factory)

TestOverwriteApp verifies that SaveApp on an existing client_id replaces the stored registration with the new metadata.

func TestPersistence

func TestPersistence(t *testing.T, factory Factory)

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

func TestSaveAndGet(t *testing.T, factory Factory)

TestSaveAndGet verifies that SaveApp followed by GetApp returns the saved registration.

Types

type Factory

type Factory func(t *testing.T) admin.AppRegistrationStore

Factory creates a fresh AppRegistrationStore for each test.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL