memory repo: allow init with existing data

This commit is contained in:
ari melody 2026-07-31 10:35:51 +01:00
parent 8bd1c556fb
commit 6eb204bfce
Signed by: ari
GPG key ID: CF99829C92678188
2 changed files with 3 additions and 3 deletions

View file

@ -13,8 +13,8 @@ type AccountRepositoryMemory struct {
var _ AccountRepository = new(AccountRepositoryMemory) var _ AccountRepository = new(AccountRepositoryMemory)
func NewAccountRepositoryMemory() *AccountRepositoryMemory { func NewAccountRepositoryMemory(accounts []*model.Account) *AccountRepositoryMemory {
return &AccountRepositoryMemory{ accounts: make([]*model.Account, 0) } return &AccountRepositoryMemory{ accounts: accounts }
} }
func (repo *AccountRepositoryMemory) GetAll() ([]*model.Account, error) { func (repo *AccountRepositoryMemory) GetAll() ([]*model.Account, error) {

View file

@ -18,7 +18,7 @@ func init() {
if err != nil { panic(err) } if err != nil { panic(err) }
defer devNullFile.Close() defer devNullFile.Close()
repo := repository.NewAccountRepositoryMemory() repo := repository.NewAccountRepositoryMemory(make([]*model.Account, 0))
service = NewAccountService( service = NewAccountService(
repo, repo,
log.New(devNullFile, "", model.DEFAULT_LOG_FLAGS), log.New(devNullFile, "", model.DEFAULT_LOG_FLAGS),