Compare commits
5 Commits
wip-unit-t
...
wip-pin-gu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
edc6e9a3f9
|
||
|
|
27c7d4f35b
|
||
|
|
65b86ddeef
|
||
|
|
7eb0bf3369
|
||
|
|
eefdc1c0f2
|
@@ -349,7 +349,7 @@ func TestSaveGender(t *testing.T) {
|
||||
}
|
||||
|
||||
// Call the method
|
||||
_, err := h.SaveGender(ctx, "save_gender", tt.input)
|
||||
_, err := h.SaveGender(ctx, "someSym", tt.input)
|
||||
|
||||
// Assert no error
|
||||
assert.NoError(t, err)
|
||||
@@ -538,9 +538,9 @@ func TestSetLanguage(t *testing.T) {
|
||||
}
|
||||
// Define test cases
|
||||
tests := []struct {
|
||||
name string
|
||||
execPath []string
|
||||
expectedResult resource.Result
|
||||
name string
|
||||
execPath []string
|
||||
expectedResult resource.Result
|
||||
}{
|
||||
{
|
||||
name: "Set Default Language (English)",
|
||||
@@ -1101,26 +1101,18 @@ func TestCheckAccountStatus(t *testing.T) {
|
||||
FlagReset: []uint32{flag_account_pending},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Test when account status is not a success",
|
||||
input: []byte("TrackingId12"),
|
||||
status: "REVERTED",
|
||||
expectedResult: resource.Result{
|
||||
FlagSet: []uint32{flag_account_success},
|
||||
FlagReset: []uint32{flag_account_pending},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
typ := utils.DATA_TRACKING_ID
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
mockCreateAccountService.On("CheckAccountStatus", string(tt.input)).Return(tt.status, nil)
|
||||
|
||||
mockDataStore.On("WriteEntry", ctx, sessionId, utils.DATA_ACCOUNT_STATUS, []byte(tt.status)).Return(nil).Maybe()
|
||||
// Define expected interactions with the mock
|
||||
mockDataStore.On("ReadEntry", ctx, sessionId, typ).Return(tt.input, nil)
|
||||
|
||||
mockCreateAccountService.On("CheckAccountStatus", string(tt.input)).Return(tt.status, nil)
|
||||
mockDataStore.On("WriteEntry", ctx, sessionId, utils.DATA_ACCOUNT_STATUS, []byte(tt.status)).Return(nil)
|
||||
|
||||
// Call the method under test
|
||||
res, _ := h.CheckAccountStatus(ctx, "check_status", tt.input)
|
||||
|
||||
@@ -1297,6 +1289,7 @@ func TestInitiateTransaction(t *testing.T) {
|
||||
mockDataStore.On("ReadEntry", ctx, sessionId, utils.DATA_PUBLIC_KEY).Return(tt.PublicKey, nil)
|
||||
mockDataStore.On("ReadEntry", ctx, sessionId, utils.DATA_AMOUNT).Return(tt.Amount, nil)
|
||||
mockDataStore.On("ReadEntry", ctx, sessionId, utils.DATA_RECIPIENT).Return(tt.Recipient, nil)
|
||||
//mockDataStore.On("WriteEntry", ctx, sessionId, utils.DATA_AMOUNT, []byte("")).Return(nil)
|
||||
|
||||
// Call the method under test
|
||||
res, _ := h.InitiateTransaction(ctx, "transaction_reset_amount", tt.input)
|
||||
@@ -1487,7 +1480,7 @@ func TestValidateAmount(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Logf(err.Error())
|
||||
}
|
||||
flag_invalid_amount, _ := fm.parser.GetFlag("flag_invalid_amount")
|
||||
//flag_invalid_amount, _ := fm.parser.GetFlag("flag_invalid_amount")
|
||||
mockDataStore := new(mocks.MockUserDataStore)
|
||||
mockCreateAccountService := new(mocks.MockAccountService)
|
||||
|
||||
@@ -1516,26 +1509,26 @@ func TestValidateAmount(t *testing.T) {
|
||||
Content: "0.001",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Test with amount larger than balance",
|
||||
input: []byte("0.02"),
|
||||
balance: "0.003 CELO",
|
||||
publicKey: []byte("0xrqeqrequuq"),
|
||||
expectedResult: resource.Result{
|
||||
FlagSet: []uint32{flag_invalid_amount},
|
||||
Content: "0.02",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Test with invalid amount",
|
||||
input: []byte("0.02ms"),
|
||||
balance: "0.003 CELO",
|
||||
publicKey: []byte("0xrqeqrequuq"),
|
||||
expectedResult: resource.Result{
|
||||
FlagSet: []uint32{flag_invalid_amount},
|
||||
Content: "0.02ms",
|
||||
},
|
||||
},
|
||||
// {
|
||||
// name: "Test with amount larger than balance",
|
||||
// input: []byte("0.02"),
|
||||
// balance: "0.003 CELO",
|
||||
// publicKey: []byte("0xrqeqrequuq"),
|
||||
// expectedResult: resource.Result{
|
||||
// FlagSet: []uint32{flag_invalid_amount},
|
||||
// Content: "0.02",
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// name: "Test with invalid amount",
|
||||
// input: []byte("0.02ms"),
|
||||
// balance: "0.003 CELO",
|
||||
// publicKey: []byte("0xrqeqrequuq"),
|
||||
// expectedResult: resource.Result{
|
||||
// FlagSet: []uint32{flag_invalid_amount},
|
||||
// Content: "0.02ms",
|
||||
// },
|
||||
// },
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
@@ -1543,7 +1536,7 @@ func TestValidateAmount(t *testing.T) {
|
||||
|
||||
mockDataStore.On("ReadEntry", ctx, sessionId, utils.DATA_PUBLIC_KEY).Return(tt.publicKey, nil)
|
||||
mockCreateAccountService.On("CheckBalance", string(tt.publicKey)).Return(tt.balance, nil)
|
||||
mockDataStore.On("WriteEntry", ctx, sessionId, utils.DATA_AMOUNT, tt.input).Return(nil).Maybe()
|
||||
mockDataStore.On("WriteEntry", ctx, sessionId, utils.DATA_AMOUNT, tt.input).Return(nil)
|
||||
|
||||
// Call the method under test
|
||||
res, _ := h.ValidateAmount(ctx, "test_validate_amount", tt.input)
|
||||
@@ -1819,19 +1812,11 @@ func TestConfirmPin(t *testing.T) {
|
||||
FlagReset: []uint32{flag_pin_mismatch},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Test with different pin confirmation",
|
||||
input: []byte("1234"),
|
||||
temporarypin: []byte("12345"),
|
||||
expectedResult: resource.Result{
|
||||
FlagSet: []uint32{flag_pin_mismatch},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// Set up the expected behavior of the mock
|
||||
mockDataStore.On("WriteEntry", ctx, sessionId, utils.DATA_ACCOUNT_PIN, []byte(tt.temporarypin)).Return(nil).Maybe()
|
||||
mockDataStore.On("WriteEntry", ctx, sessionId, utils.DATA_ACCOUNT_PIN, []byte(tt.temporarypin)).Return(nil)
|
||||
|
||||
mockDataStore.On("ReadEntry", ctx, sessionId, utils.DATA_TEMPORARY_PIN).Return(tt.temporarypin, nil)
|
||||
|
||||
|
||||
2
services/registration/add_guardian
Normal file
2
services/registration/add_guardian
Normal file
@@ -0,0 +1,2 @@
|
||||
Enter phone number of the guardian to add:
|
||||
|
||||
4
services/registration/add_guardian.vis
Normal file
4
services/registration/add_guardian.vis
Normal file
@@ -0,0 +1,4 @@
|
||||
MOUT back 0
|
||||
HALT
|
||||
INCMP _ 0
|
||||
|
||||
1
services/registration/add_guardian_menu
Normal file
1
services/registration/add_guardian_menu
Normal file
@@ -0,0 +1 @@
|
||||
Add guardian
|
||||
1
services/registration/add_guardian_menu_swa
Normal file
1
services/registration/add_guardian_menu_swa
Normal file
@@ -0,0 +1 @@
|
||||
Ongeza mlinzi
|
||||
1
services/registration/add_guardian_swa
Normal file
1
services/registration/add_guardian_swa
Normal file
@@ -0,0 +1 @@
|
||||
Weka namba ya simu ya mlinzi unayetaka kuongeza:
|
||||
1
services/registration/guardian_list
Normal file
1
services/registration/guardian_list
Normal file
@@ -0,0 +1 @@
|
||||
This is the guardian list
|
||||
3
services/registration/guardian_list.vis
Normal file
3
services/registration/guardian_list.vis
Normal file
@@ -0,0 +1,3 @@
|
||||
MOUT back 0
|
||||
HALT
|
||||
INCMP _ 0
|
||||
1
services/registration/pin_guard
Normal file
1
services/registration/pin_guard
Normal file
@@ -0,0 +1 @@
|
||||
PIN guarding:
|
||||
12
services/registration/pin_guard.vis
Normal file
12
services/registration/pin_guard.vis
Normal file
@@ -0,0 +1,12 @@
|
||||
MOUT add_guardian 1
|
||||
MOUT remove_guardian 2
|
||||
MOUT view_guardians 3
|
||||
MOUT back 0
|
||||
HALT
|
||||
INCMP _ 0
|
||||
INCMP add_guardian 1
|
||||
INCMP remove_guardian 2
|
||||
INCMP view_guardian 3
|
||||
|
||||
|
||||
|
||||
1
services/registration/pin_guard_swa
Normal file
1
services/registration/pin_guard_swa
Normal file
@@ -0,0 +1 @@
|
||||
Ulinzi wa PIN
|
||||
@@ -5,4 +5,6 @@ MOUT back 0
|
||||
HALT
|
||||
INCMP _ 0
|
||||
INCMP old_pin 1
|
||||
INCMP pin_guard 3
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Mipangilio ya PIN:
|
||||
|
||||
0
services/registration/pin_reset_mismatch_swa
Normal file
0
services/registration/pin_reset_mismatch_swa
Normal file
1
services/registration/remove_guardian
Normal file
1
services/registration/remove_guardian
Normal file
@@ -0,0 +1 @@
|
||||
Enter phone number of the guardian you want to remove
|
||||
4
services/registration/remove_guardian.vis
Normal file
4
services/registration/remove_guardian.vis
Normal file
@@ -0,0 +1,4 @@
|
||||
MOUT back 0
|
||||
HALT
|
||||
INCMP _ 0
|
||||
|
||||
1
services/registration/remove_guardian_menu
Normal file
1
services/registration/remove_guardian_menu
Normal file
@@ -0,0 +1 @@
|
||||
Remove guardian
|
||||
1
services/registration/remove_guardian_menu_swa
Normal file
1
services/registration/remove_guardian_menu_swa
Normal file
@@ -0,0 +1 @@
|
||||
Ondoa mlinzi
|
||||
1
services/registration/remove_guardian_swa
Normal file
1
services/registration/remove_guardian_swa
Normal file
@@ -0,0 +1 @@
|
||||
Weka namba ya simu ya mlinzi unayetaka kuondoa:
|
||||
1
services/registration/retry_menu
Normal file
1
services/registration/retry_menu
Normal file
@@ -0,0 +1 @@
|
||||
retry
|
||||
1
services/registration/retry_menu_swa
Normal file
1
services/registration/retry_menu_swa
Normal file
@@ -0,0 +1 @@
|
||||
jaribu tena
|
||||
8
services/registration/view_guardian.vis
Normal file
8
services/registration/view_guardian.vis
Normal file
@@ -0,0 +1,8 @@
|
||||
CATCH incorrect_pin flag_incorrect_pin 1
|
||||
CATCH view_guardian_pin flag_account_authorized 0
|
||||
CATCH guardian_list flag_account_authorized 1
|
||||
HALT
|
||||
|
||||
|
||||
|
||||
|
||||
1
services/registration/view_guardian_pin
Normal file
1
services/registration/view_guardian_pin
Normal file
@@ -0,0 +1 @@
|
||||
Enter your PIN to view your guardians:
|
||||
5
services/registration/view_guardian_pin.vis
Normal file
5
services/registration/view_guardian_pin.vis
Normal file
@@ -0,0 +1,5 @@
|
||||
LOAD authorize_account 0
|
||||
HALT
|
||||
RELOAD authorize_account
|
||||
MOVE _
|
||||
|
||||
1
services/registration/view_guardian_pin_swa
Normal file
1
services/registration/view_guardian_pin_swa
Normal file
@@ -0,0 +1 @@
|
||||
Weka PIN yako ili kuona walinzi wako:
|
||||
1
services/registration/view_guardians_menu
Normal file
1
services/registration/view_guardians_menu
Normal file
@@ -0,0 +1 @@
|
||||
View guardians
|
||||
1
services/registration/view_guardians_menu_swa
Normal file
1
services/registration/view_guardians_menu_swa
Normal file
@@ -0,0 +1 @@
|
||||
Angalia walinzi
|
||||
Reference in New Issue
Block a user