Add voucherdata call to test accountservices
This commit is contained in:
parent
7189235bee
commit
2c30ccc405
@ -1,8 +1,12 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.defalsify.org/vise.git/db"
|
"context"
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"git.defalsify.org/vise.git/db"
|
||||||
|
"git.defalsify.org/vise.git/resource"
|
||||||
|
"git.defalsify.org/vise.git/persist"
|
||||||
"git.grassecon.net/urdt/ussd/internal/storage"
|
"git.grassecon.net/urdt/ussd/internal/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,3 +17,36 @@ func StoreToDb(store *UserDataStore) db.Db {
|
|||||||
func StoreToPrefixDb(store *UserDataStore, pfx []byte) storage.PrefixDb {
|
func StoreToPrefixDb(store *UserDataStore, pfx []byte) storage.PrefixDb {
|
||||||
return storage.NewSubPrefixDb(store.Db, pfx)
|
return storage.NewSubPrefixDb(store.Db, pfx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type StorageServices interface {
|
||||||
|
GetPersister(ctx context.Context) (*persist.Persister, error)
|
||||||
|
GetUserdataDb(ctx context.Context) (db.Db, error)
|
||||||
|
GetResource(ctx context.Context) (resource.Resource, error)
|
||||||
|
EnsureDbDir() error
|
||||||
|
}
|
||||||
|
|
||||||
|
type StorageService struct {
|
||||||
|
svc *storage.MenuStorageService
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewStorageService(dbDir string) *StorageService {
|
||||||
|
return &StorageService{
|
||||||
|
svc: storage.NewMenuStorageService(dbDir, ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func(ss *StorageService) GetPersister(ctx context.Context) (*persist.Persister, error) {
|
||||||
|
return ss.svc.GetPersister(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func(ss *StorageService) GetUserdataDb(ctx context.Context) (db.Db, error) {
|
||||||
|
return ss.svc.GetUserdataDb(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func(ss *StorageService) GetResource(ctx context.Context) (resource.Resource, error) {
|
||||||
|
return nil, errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func(ss *StorageService) EnsureDbDir() error {
|
||||||
|
return ss.svc.EnsureDbDir()
|
||||||
|
}
|
||||||
|
@ -38,3 +38,8 @@ func (m *MockAccountService) FetchTransactions(ctx context.Context, publicKey st
|
|||||||
args := m.Called(publicKey)
|
args := m.Called(publicKey)
|
||||||
return args.Get(0).([]dataserviceapi.Last10TxResponse), args.Error(1)
|
return args.Get(0).([]dataserviceapi.Last10TxResponse), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func(m MockAccountService) VoucherData(ctx context.Context, address string) (*models.VoucherDataResult, error) {
|
||||||
|
args := m.Called(address)
|
||||||
|
return args.Get(0).(*models.VoucherDataResult), args.Error(1)
|
||||||
|
}
|
||||||
|
@ -46,3 +46,7 @@ func (tas *TestAccountService) FetchVouchers(ctx context.Context, publicKey stri
|
|||||||
func (tas *TestAccountService) FetchTransactions(ctx context.Context, publicKey string) ([]dataserviceapi.Last10TxResponse, error) {
|
func (tas *TestAccountService) FetchTransactions(ctx context.Context, publicKey string) ([]dataserviceapi.Last10TxResponse, error) {
|
||||||
return []dataserviceapi.Last10TxResponse{}, nil
|
return []dataserviceapi.Last10TxResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func(m TestAccountService) VoucherData(ctx context.Context, address string) (*models.VoucherDataResult, error) {
|
||||||
|
return &models.VoucherDataResult{}, nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user