Documentation
¶
Overview ¶
Package authstoretest checks baseAgent.AuthStore implementations against the contract documented on baseAgent.AuthStore.
Call Run from a test in the store's package, with two stores over the same database:
func TestConformance(t *testing.T) {
authstoretest.Run(t, func(t *testing.T) baseAgent.AuthStore {
return newTestStore(t)
})
}
Run it with go test -timeout: a broken lock usually deadlocks rather than failing.
Index ¶
- func Run(t *testing.T, newStore func(t *testing.T) baseAgent.AuthStore)
- type MemoryStore
- func (s *MemoryStore) Delete(ctx context.Context, ownerID, namespace, name string) error
- func (s *MemoryStore) Get(ctx context.Context, ownerID, namespace, name string) ([]byte, error)
- func (s *MemoryStore) List(ctx context.Context, ownerID, namespace string) ([]string, error)
- func (s *MemoryStore) Modify(ctx context.Context, ownerID, namespace, name string, ...) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run checks the store returned by newStore against the AuthStore contract. newStore is called twice per subtest, and the subtest uses both stores, often at once. They must share one database, as two processes would, so a lock held only in memory fails. Every subtest uses fresh owner IDs, so the stores may share a database with other tests.
Types ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory baseAgent.AuthStore. It is a reference implementation of the contract and a store for tests and single-process apps. Values are not encrypted, and it keeps a small lock for every key it has seen.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore returns an empty MemoryStore.
func (*MemoryStore) Delete ¶
func (s *MemoryStore) Delete(ctx context.Context, ownerID, namespace, name string) error