forked from grassrootseconomics/visedriver
Add mem storage service
This commit is contained in:
parent
5bf0a0e858
commit
5228aef088
@ -7,7 +7,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DBTYPE_MEM = iota
|
DBTYPE_NONE = iota
|
||||||
|
DBTYPE_MEM
|
||||||
DBTYPE_GDBM
|
DBTYPE_GDBM
|
||||||
DBTYPE_POSTGRES
|
DBTYPE_POSTGRES
|
||||||
)
|
)
|
||||||
|
42
testutil/mocks/storage.go
Normal file
42
testutil/mocks/storage.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package mocks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"git.defalsify.org/vise.git/db"
|
||||||
|
memdb "git.defalsify.org/vise.git/db/mem"
|
||||||
|
"git.defalsify.org/vise.git/resource"
|
||||||
|
"git.defalsify.org/vise.git/persist"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MemStorageService struct {
|
||||||
|
Db db.Db
|
||||||
|
pe *persist.Persister
|
||||||
|
rs resource.Resource
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMemStorageService(ctx context.Context) *MemStorageService {
|
||||||
|
svc := &MemStorageService{
|
||||||
|
Db: memdb.NewMemDb(),
|
||||||
|
}
|
||||||
|
err := svc.Db.Connect(ctx, "")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
svc.pe = persist.NewPersister(svc.Db)
|
||||||
|
svc.rs = resource.NewMenuResource()
|
||||||
|
return svc
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mss *MemStorageService) GetPersister(ctx context.Context) (*persist.Persister, error) {
|
||||||
|
return mss.pe, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mss *MemStorageService) GetUserdataDb(ctx context.Context) (db.Db, error) {
|
||||||
|
return mss.Db, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mss *MemStorageService) GetResource(ctx context.Context) (resource.Resource, error) {
|
||||||
|
return mss.rs, nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user