From 01c13ec581b029add5bcb6eb432d84f9e4897a55 Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Sat, 7 Sep 2024 16:25:29 +0300 Subject: [PATCH] make packKey accessible from tests --- internal/utils/db.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/utils/db.go b/internal/utils/db.go index 32fb804..5b128f6 100644 --- a/internal/utils/db.go +++ b/internal/utils/db.go @@ -33,15 +33,16 @@ func typToBytes(typ DataTyp) []byte { return b[:] } -func packKey(typ DataTyp, data []byte) []byte { +func PackKey(typ DataTyp, data []byte) []byte { v := typToBytes(typ) return append(v, data...) } func ReadEntry(ctx context.Context, store db.Db, sessionId string, typ DataTyp) ([]byte, error) { + store.SetPrefix(db.DATATYPE_USERDATA) store.SetSession(sessionId) - k := packKey(typ, []byte(sessionId)) + k := PackKey(typ, []byte(sessionId)) b, err := store.Get(ctx, k) if err != nil { return nil, err @@ -52,6 +53,6 @@ func ReadEntry(ctx context.Context, store db.Db, sessionId string, typ DataTyp) func WriteEntry(ctx context.Context, store db.Db, sessionId string, typ DataTyp, value []byte) error { store.SetPrefix(db.DATATYPE_USERDATA) store.SetSession(sessionId) - k := packKey(typ, []byte(sessionId)) + k := PackKey(typ, []byte(sessionId)) return store.Put(ctx, k, value) }