Compare commits

...

33 Commits

Author SHA1 Message Date
bed7f58e81 Merge pull request 'alfred/test-updates' (#15) from alfred/test-updates into master
Reviewed-on: #15
2025-02-13 09:58:45 +01:00
07fd1110ed
added documentation lines 2025-02-11 13:22:32 +03:00
2f1dbb9147
added TestClearTemporaryValue 2025-02-11 13:10:56 +03:00
c324e29aea
added test case to the TestCheckVouchers 2025-02-11 13:00:23 +03:00
f91056cca2 Merge branch 'master' into alfred/test-updates 2025-02-11 12:53:41 +03:00
1190c5b6f2 Merge branch 'master' into alfred/test-updates 2025-02-06 15:19:40 +03:00
14df16098c
Updated tests to include the mockState 2025-02-06 15:10:15 +03:00
1cdd5a37ae Merge branch 'master' into alfred/test-updates 2025-02-06 15:02:18 +03:00
c78081fb84
added TestInsertOrShift 2025-02-04 11:42:14 +03:00
ff3c597158
added TestUpdateAllProfileItems 2025-02-04 11:03:23 +03:00
09c5f3a14c
added TestInsertProfileItems 2025-02-04 10:30:39 +03:00
5a586eb67a
added TestConstructAccountAlias 2025-01-27 13:31:00 +03:00
6a945f8f20
added TestResetUnregisteredNumber 2025-01-27 12:53:02 +03:00
39f8c86e8b
added TestResetValidPin 2025-01-27 12:50:46 +03:00
73b501c8aa
removed left over commented code 2025-01-27 12:42:48 +03:00
a6cd4b5fca
added TestResetOthersPin 2025-01-27 12:36:04 +03:00
d47bc6c241 Merge branch 'master' into alfred/test-updates 2025-01-27 12:23:13 +03:00
dd55906e70
added TestGetCurrentProfileInfo 2025-01-27 11:35:05 +03:00
6fdf3735d0
added TestCheckBlockedNumPinMisMatch 2025-01-27 10:52:43 +03:00
b492421851
enhanced the TestSaveOthersTemporaryPin 2025-01-27 10:40:35 +03:00
128c0162d2
added TestSaveOthersTemporaryPin 2025-01-27 02:13:53 +03:00
ebe94c705f
added TestValidateBlockedNumber 2025-01-27 01:46:14 +03:00
df0c1b3429
added TestQuitWithHelp and TestShowBlockedAccount 2025-01-27 01:25:01 +03:00
d66fd894bc
added TestMaxAmount 2025-01-27 01:17:44 +03:00
28185fc2c5
added TestRetrieveBlockedNumber 2025-01-27 01:05:32 +03:00
64a87231ca
removed redundant type from array 2025-01-24 15:43:42 +03:00
0e480e3d55
enhanced the TestViewTransactionStatement 2025-01-23 16:08:04 +03:00
ffea1a0b96
added TestViewTransactionStatement 2025-01-23 15:54:50 +03:00
be5bd16616
added TestGetTransactionsList 2025-01-23 15:06:12 +03:00
93723616f6
added TestCheckTransactions 2025-01-23 13:42:17 +03:00
c9257ba0d6
added TestPersistInitialLanguageCode 2025-01-23 11:47:12 +03:00
caabf4f8af
updated the structure of TestPersistLanguageCode 2025-01-23 11:30:25 +03:00
f884b19012
added TestCheckBlockedStatus 2025-01-23 11:29:57 +03:00
4 changed files with 1258 additions and 14 deletions

View File

@ -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.
@ -2307,6 +2305,7 @@ func (h *MenuHandlers) ViewTransactionStatement(ctx context.Context, sym string,
return res, nil
}
// persistInitialLanguageCode receives an initial language code and persists it to the store
func (h *MenuHandlers) persistInitialLanguageCode(ctx context.Context, sessionId string, code string) error {
store := h.userdataStore
_, err := store.ReadEntry(ctx, sessionId, storedb.DATA_INITIAL_LANGUAGE_CODE)
@ -2339,6 +2338,8 @@ func (h *MenuHandlers) persistLanguageCode(ctx context.Context, code string) err
return h.persistInitialLanguageCode(ctx, sessionId, code)
}
// constructAccountAlias retrieves and alias based on the first and family name
// and writes the result in DATA_ACCOUNT_ALIAS
func (h *MenuHandlers) constructAccountAlias(ctx context.Context) error {
var alias string
store := h.userdataStore
@ -2383,6 +2384,8 @@ func (h *MenuHandlers) constructAccountAlias(ctx context.Context) error {
return nil
}
// ClearTemporaryValue empties the DATA_TEMPORARY_VALUE at the main menu to prevent
// previously stored data from being accessed
func (h *MenuHandlers) ClearTemporaryValue(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result
sessionId, ok := ctx.Value("SessionId").(string)

File diff suppressed because it is too large Load Diff

View File

@ -66,7 +66,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)

42
profile/profile_test.go Normal file
View File

@ -0,0 +1,42 @@
package profile
import (
"testing"
"github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
)
func TestInsertOrShift(t *testing.T) {
tests := []struct {
name string
profile Profile
index int
value string
expected []string
}{
{
name: "Insert within range",
profile: Profile{ProfileItems: []string{"A", "B", "C"}, Max: 5},
index: 1,
value: "X",
expected: []string{"A", "X"},
},
{
name: "Insert beyond range",
profile: Profile{ProfileItems: []string{"A"}, Max: 5},
index: 3,
value: "Y",
expected: []string{"A", "0", "0", "Y"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := tt.profile
p.InsertOrShift(tt.index, tt.value)
require.NotNil(t, p.ProfileItems)
assert.Equal(t, tt.expected, p.ProfileItems)
})
}
}