From 54b2088842cc6ff96ad228283da9ff75f5a84de4 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Mon, 24 Mar 2025 19:53:02 +0300 Subject: [PATCH] Pass correct arguments in the TestGetVoucherData --- store/vouchers_test.go | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/store/vouchers_test.go b/store/vouchers_test.go index a98ffc3..711f93b 100644 --- a/store/vouchers_test.go +++ b/store/vouchers_test.go @@ -8,7 +8,6 @@ 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" storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db" dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api" @@ -77,16 +76,8 @@ func TestProcessVouchers(t *testing.T) { } func TestGetVoucherData(t *testing.T) { - ctx := context.Background() - - db := memdb.NewMemDb() - err := db.Connect(ctx, "") - if err != nil { - t.Fatal(err) - } - - prefix := storedb.ToBytes(visedb.DATATYPE_USERDATA) - spdb := storedb.NewSubPrefixDb(db, prefix) + ctx, store := InitializeTestDb(t) + sessionId := "session123" // Test voucher data mockData := map[storedb.DataTyp][]byte{ @@ -98,13 +89,13 @@ func TestGetVoucherData(t *testing.T) { // Put the data for key, value := range mockData { - err = spdb.Put(ctx, []byte(storedb.ToBytes(key)), []byte(value)) + err := store.WriteEntry(ctx, sessionId, key, []byte(value)) if err != nil { t.Fatal(err) } } - result, err := GetVoucherData(ctx, spdb, "1") + result, err := GetVoucherData(ctx, store, sessionId, "1") assert.NoError(t, err) assert.Equal(t, "SRF", result.TokenSymbol)