From bd8631eb05463a5d3c8b4316523f7ab84f3423ca Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Mon, 28 Jul 2025 16:15:21 +0300 Subject: [PATCH] update the TestCheckBlockedStatus to account for the udpated functionality --- handlers/application/account_status_test.go | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/handlers/application/account_status_test.go b/handlers/application/account_status_test.go index fc7e09c..873e2df 100644 --- a/handlers/application/account_status_test.go +++ b/handlers/application/account_status_test.go @@ -5,6 +5,7 @@ import ( "testing" "git.defalsify.org/vise.git/resource" + "git.defalsify.org/vise.git/state" "git.grassecon.net/grassrootseconomics/sarafu-api/models" "git.grassecon.net/grassrootseconomics/sarafu-api/testutil/mocks" storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db" @@ -93,16 +94,24 @@ func TestCheckBlockedStatus(t *testing.T) { } flag_account_blocked, _ := fm.GetFlag("flag_account_blocked") flag_account_pin_reset, _ := fm.GetFlag("flag_account_pin_reset") + flag_pin_set, _ := fm.GetFlag("flag_pin_set") + flag_language_set, _ := fm.GetFlag("flag_language_set") + + // Set the flag in the State + mockState := state.NewState(128) h := &MenuHandlers{ userdataStore: store, flagManager: fm, + st: mockState, } tests := []struct { name string currentWrongPinAttempts string expectedResult resource.Result + languageSet bool + PinSet bool }{ { name: "Currently blocked account", @@ -118,6 +127,16 @@ func TestCheckBlockedStatus(t *testing.T) { FlagReset: []uint32{flag_account_pin_reset, flag_account_blocked}, }, }, + { + name: "Valid account with reset language and PIN flags", + currentWrongPinAttempts: "0", + languageSet: true, + PinSet: true, + expectedResult: resource.Result{ + FlagReset: []uint32{flag_account_pin_reset, flag_account_blocked}, + FlagSet: []uint32{flag_pin_set, flag_language_set}, + }, + }, } for _, tt := range tests { @@ -126,6 +145,18 @@ func TestCheckBlockedStatus(t *testing.T) { t.Fatal(err) } + if tt.languageSet { + if err := store.WriteEntry(ctx, sessionId, storedb.DATA_SELECTED_LANGUAGE_CODE, []byte("eng")); err != nil { + t.Fatal(err) + } + } + + if tt.PinSet { + if err := store.WriteEntry(ctx, sessionId, storedb.DATA_ACCOUNT_PIN, []byte("hasedPinValue")); err != nil { + t.Fatal(err) + } + } + res, err := h.CheckBlockedStatus(ctx, "", []byte("")) assert.NoError(t, err)