Compare commits
2 Commits
d47bc6c241
...
73b501c8aa
Author | SHA1 | Date | |
---|---|---|---|
73b501c8aa | |||
a6cd4b5fca |
@ -102,14 +102,12 @@ func NewMenuHandlers(appFlags *FlagManager, userdataStore db.Db, accountService
|
||||
return h, nil
|
||||
}
|
||||
|
||||
// WithPersister sets persister instance to the handlers.
|
||||
// func (h *MenuHandlers) WithPersister(pe *persist.Persister) *MenuHandlers {
|
||||
// SetPersister sets persister instance to the handlers.
|
||||
func (h *MenuHandlers) SetPersister(pe *persist.Persister) {
|
||||
if h.pe != nil {
|
||||
panic("persister already set")
|
||||
}
|
||||
h.pe = pe
|
||||
//return h
|
||||
}
|
||||
|
||||
// Init initializes the handler for a new session.
|
||||
|
@ -266,7 +266,6 @@ func TestWithPersister(t *testing.T) {
|
||||
h.SetPersister(p)
|
||||
|
||||
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) {
|
||||
@ -3186,3 +3185,36 @@ 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,7 +60,6 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
//appHandlers = appHandlers.WithPersister(ls.Pe)
|
||||
appHandlers.SetPersister(ls.Pe)
|
||||
ls.DbRs.AddLocalFunc("check_blocked_status", appHandlers.CheckBlockedStatus)
|
||||
ls.DbRs.AddLocalFunc("set_language", appHandlers.SetLanguage)
|
||||
|
Loading…
Reference in New Issue
Block a user