add in-memory DB for accounts, with tests!

This commit is contained in:
ari melody 2026-07-31 04:20:39 +01:00
parent 49e14b5bc5
commit 5a540184c9
Signed by: ari
GPG key ID: CF99829C92678188
9 changed files with 534 additions and 45 deletions

View file

@ -3,12 +3,15 @@ package account
import "arimelody-web/model"
type AccountRepository interface {
GetAll() ([]model.Account, error)
GetAll() ([]*model.Account, error)
GetCount() (int, error)
GetByID(id string) (*model.Account, error)
GetByUsername(username string) (*model.Account, error)
GetByEmail(email string) (*model.Account, error)
GetBySession(sessionToken string) (*model.Account, error)
// Pulled this function: Cross-cutting concerns between accounts and sessions.
// Instead, fetch account ID from session and use GetByID()
// GetBySession(sessionToken string) (*model.Account, error)
// Create an account, returning the new account ID.
Create(username string, password string, email *string, avatarURL *string) (string, error)
@ -23,11 +26,12 @@ type AccountRepository interface {
ChangeAvatarURL(id string, avatarURL string) error
RemoveAvatar(id string) error
Delete(accountID string) error
Delete(id string) error
// Increment the number of account login failure attempts,
// returning the current fail count.
IncrementFails(accountID string) (int, error)
Lock(accountID string) error
Unlock(accountID string) error
IncrementFails(id string) (int, error)
ResetFails(id string) error
Lock(id string) error
Unlock(id string) error
}