Compare commits
No commits in common. "73b501c8aa806019d1a7a31446511770332ce1b5" and "d47bc6c24127e53595e80bb6d29d63d6469d87f4" have entirely different histories.
73b501c8aa
...
d47bc6c241
@ -102,12 +102,14 @@ func NewMenuHandlers(appFlags *FlagManager, userdataStore db.Db, accountService
|
|||||||
return h, nil
|
return h, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetPersister sets persister instance to the handlers.
|
// WithPersister sets persister instance to the handlers.
|
||||||
|
// func (h *MenuHandlers) WithPersister(pe *persist.Persister) *MenuHandlers {
|
||||||
func (h *MenuHandlers) SetPersister(pe *persist.Persister) {
|
func (h *MenuHandlers) SetPersister(pe *persist.Persister) {
|
||||||
if h.pe != nil {
|
if h.pe != nil {
|
||||||
panic("persister already set")
|
panic("persister already set")
|
||||||
}
|
}
|
||||||
h.pe = pe
|
h.pe = pe
|
||||||
|
//return h
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init initializes the handler for a new session.
|
// Init initializes the handler for a new session.
|
||||||
|
|||||||
@ -266,6 +266,7 @@ func TestWithPersister(t *testing.T) {
|
|||||||
h.SetPersister(p)
|
h.SetPersister(p)
|
||||||
|
|
||||||
assert.Equal(t, p, h.pe, "The persister should be set correctly.")
|
assert.Equal(t, p, h.pe, "The persister should be set correctly.")
|
||||||
|
//assert.Equal(t, h, result, "The returned handler should be the same instance.")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWithPersister_PanicWhenAlreadySet(t *testing.T) {
|
func TestWithPersister_PanicWhenAlreadySet(t *testing.T) {
|
||||||
@ -3185,36 +3186,3 @@ func TestGetCurrentProfileInfo(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestResetOthersPin(t *testing.T) {
|
|
||||||
sessionId := "session123"
|
|
||||||
blockedNumber := "+254712345678"
|
|
||||||
testPin := "1234"
|
|
||||||
|
|
||||||
ctx, userStore := InitializeTestStore(t)
|
|
||||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
|
||||||
|
|
||||||
hashedPIN, err := pin.HashPIN(testPin)
|
|
||||||
if err != nil {
|
|
||||||
logg.ErrorCtxf(ctx, "failed to hash testPin", "error", err)
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
h := &MenuHandlers{
|
|
||||||
userdataStore: userStore,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write initial data to the store
|
|
||||||
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_BLOCKED_NUMBER, []byte(blockedNumber))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
err = userStore.WriteEntry(ctx, blockedNumber, storedb.DATA_TEMPORARY_VALUE, []byte(hashedPIN))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = h.ResetOthersPin(ctx, "reset_others_pin", []byte(""))
|
|
||||||
|
|
||||||
assert.NoError(t, err)
|
|
||||||
}
|
|
||||||
|
|||||||
@ -60,6 +60,7 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
//appHandlers = appHandlers.WithPersister(ls.Pe)
|
||||||
appHandlers.SetPersister(ls.Pe)
|
appHandlers.SetPersister(ls.Pe)
|
||||||
ls.DbRs.AddLocalFunc("check_blocked_status", appHandlers.CheckBlockedStatus)
|
ls.DbRs.AddLocalFunc("check_blocked_status", appHandlers.CheckBlockedStatus)
|
||||||
ls.DbRs.AddLocalFunc("set_language", appHandlers.SetLanguage)
|
ls.DbRs.AddLocalFunc("set_language", appHandlers.SetLanguage)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user