Use the DATATYPE_USERDATA as the prefix for the NewSubPrefixDb func

This commit is contained in:
Alfred Kamanda 2024-12-05 17:02:26 +03:00
parent a659fb06fa
commit 589a94216b
Signed by untrusted user: Alfred-mk
GPG Key ID: 7EA3D01708908703
3 changed files with 11 additions and 4 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
visedb "git.defalsify.org/vise.git/db"
memdb "git.defalsify.org/vise.git/db/mem"
"git.grassecon.net/urdt/ussd/internal/storage"
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
@ -83,7 +84,9 @@ func TestGetVoucherData(t *testing.T) {
if err != nil {
t.Fatal(err)
}
spdb := storage.NewSubPrefixDb(db, []byte("vouchers"))
prefix := IntToBytes(visedb.DATATYPE_USERDATA)
spdb := storage.NewSubPrefixDb(db, prefix)
// Test voucher data
mockData := map[DataTyp][]byte{

View File

@ -85,8 +85,10 @@ func NewHandlers(appFlags *asm.FlagParser, userdataStore db.Db, adminstore *util
userDb := &common.UserDataStore{
Db: userdataStore,
}
// Instantiate the SubPrefixDb with "vouchers" prefix
prefixDb := storage.NewSubPrefixDb(userdataStore, []byte("vouchers"))
// Instantiate the SubPrefixDb with "DATATYPE_USERDATA" prefix
prefix := common.IntToBytes(db.DATATYPE_USERDATA)
prefixDb := storage.NewSubPrefixDb(userdataStore, prefix)
h := &Handlers{
userdataStore: userDb,

View File

@ -22,6 +22,7 @@ import (
testdataloader "github.com/peteole/testdata-loader"
"github.com/stretchr/testify/require"
visedb "git.defalsify.org/vise.git/db"
memdb "git.defalsify.org/vise.git/db/mem"
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
)
@ -56,7 +57,8 @@ func InitializeTestSubPrefixDb(t *testing.T, ctx context.Context) *storage.SubPr
if err != nil {
t.Fatal(err)
}
spdb := storage.NewSubPrefixDb(db, []byte("vouchers"))
prefix := common.IntToBytes(visedb.DATATYPE_USERDATA)
spdb := storage.NewSubPrefixDb(db, prefix)
return spdb
}