From 6eb204bfce61a4c0e821b7a457ef0708e2189406 Mon Sep 17 00:00:00 2001 From: ari melody Date: Fri, 31 Jul 2026 10:35:51 +0100 Subject: [PATCH] memory repo: allow init with existing data --- repository/account/memory.go | 4 ++-- service/account/account_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/repository/account/memory.go b/repository/account/memory.go index 975ed2b..7cce061 100644 --- a/repository/account/memory.go +++ b/repository/account/memory.go @@ -13,8 +13,8 @@ type AccountRepositoryMemory struct { var _ AccountRepository = new(AccountRepositoryMemory) -func NewAccountRepositoryMemory() *AccountRepositoryMemory { - return &AccountRepositoryMemory{ accounts: make([]*model.Account, 0) } +func NewAccountRepositoryMemory(accounts []*model.Account) *AccountRepositoryMemory { + return &AccountRepositoryMemory{ accounts: accounts } } func (repo *AccountRepositoryMemory) GetAll() ([]*model.Account, error) { diff --git a/service/account/account_test.go b/service/account/account_test.go index f12fdaf..0c9a372 100644 --- a/service/account/account_test.go +++ b/service/account/account_test.go @@ -18,7 +18,7 @@ func init() { if err != nil { panic(err) } defer devNullFile.Close() - repo := repository.NewAccountRepositoryMemory() + repo := repository.NewAccountRepositoryMemory(make([]*model.Account, 0)) service = NewAccountService( repo, log.New(devNullFile, "", model.DEFAULT_LOG_FLAGS),