diff --git a/common/vouchers_test.go b/common/vouchers_test.go index e6f449d..560fb5b 100644 --- a/common/vouchers_test.go +++ b/common/vouchers_test.go @@ -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{ diff --git a/internal/handlers/ussd/menuhandler.go b/internal/handlers/ussd/menuhandler.go index 14cfc50..812c897 100644 --- a/internal/handlers/ussd/menuhandler.go +++ b/internal/handlers/ussd/menuhandler.go @@ -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, diff --git a/internal/handlers/ussd/menuhandler_test.go b/internal/handlers/ussd/menuhandler_test.go index 9fabe97..1aa7c28 100644 --- a/internal/handlers/ussd/menuhandler_test.go +++ b/internal/handlers/ussd/menuhandler_test.go @@ -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 }