memory repo: allow init with existing data
This commit is contained in:
parent
8bd1c556fb
commit
6eb204bfce
2 changed files with 3 additions and 3 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue