2024-11-04 00:08:50 +01:00
|
|
|
package testutil
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"git.defalsify.org/vise.git/persist"
|
|
|
|
"git.defalsify.org/vise.git/resource"
|
|
|
|
"git.defalsify.org/vise.git/db"
|
|
|
|
)
|
|
|
|
|
2024-11-04 00:10:44 +01:00
|
|
|
// TestStorageService wraps db for nats subscription.
|
2024-11-04 00:08:50 +01:00
|
|
|
type TestStorageService struct {
|
|
|
|
Store db.Db
|
|
|
|
}
|
2024-11-04 00:10:44 +01:00
|
|
|
|
|
|
|
// GetUserdataDb implements urdt/ussd/common.StorageServices.
|
2024-11-04 00:08:50 +01:00
|
|
|
func(ss *TestStorageService) GetUserdataDb(ctx context.Context) (db.Db, error) {
|
|
|
|
return ss.Store, nil
|
|
|
|
}
|
|
|
|
|
2024-11-04 00:10:44 +01:00
|
|
|
// GetPersister implements urdt/ussd/common.StorageServices.
|
2024-11-04 00:08:50 +01:00
|
|
|
func(ts *TestStorageService) GetPersister(ctx context.Context) (*persist.Persister, error) {
|
2024-11-04 00:53:36 +01:00
|
|
|
return persist.NewPersister(ts.Store), nil
|
2024-11-04 00:08:50 +01:00
|
|
|
}
|
|
|
|
|
2024-11-04 00:10:44 +01:00
|
|
|
// GetResource implements urdt/ussd/common.StorageServices.
|
2024-11-04 00:08:50 +01:00
|
|
|
func(ts *TestStorageService) GetResource(ctx context.Context) (resource.Resource, error) {
|
|
|
|
return nil, errors.New("not implemented")
|
|
|
|
}
|
|
|
|
|
2024-11-04 00:10:44 +01:00
|
|
|
// EnsureDbDir implements urdt/ussd/common.StorageServices.
|
2024-11-04 00:08:50 +01:00
|
|
|
func(ss *TestStorageService) EnsureDbDir() error {
|
|
|
|
return nil
|
|
|
|
}
|