diff --git a/internal/handlers/ussd/menuhandler_test.go b/internal/handlers/ussd/menuhandler_test.go index 22c02e9..3c32ee0 100644 --- a/internal/handlers/ussd/menuhandler_test.go +++ b/internal/handlers/ussd/menuhandler_test.go @@ -33,6 +33,11 @@ var ( flagsPath = path.Join(baseDir, "services", "registration", "pp.csv") ) +// mockReplaceSeparator function +var mockReplaceSeparator = func(input string) string { + return strings.ReplaceAll(input, ":", ": ") +} + // InitializeTestStore sets up and returns an in-memory database and store. func InitializeTestStore(t *testing.T) (context.Context, *common.UserDataStore) { ctx := context.Background() @@ -74,11 +79,6 @@ func TestNewHandlers(t *testing.T) { accountService := testservice.TestAccountService{} - // Mock function for replaceSeparator - mockReplaceSeparator := func(input string) string { - return strings.ReplaceAll(input, ":", ": ") - } - // Test case for valid UserDataStore t.Run("Valid UserDataStore", func(t *testing.T) { handlers, err := NewHandlers(fm.parser, store, nil, &accountService, mockReplaceSeparator) @@ -2007,15 +2007,10 @@ func TestGetVoucherList(t *testing.T) { spdb := InitializeTestSubPrefixDb(t, ctx) - // Mock replaceSeparator function - replaceSeparator := func(input string) string { - return strings.ReplaceAll(input, ":", ": ") - } - // Initialize Handlers h := &Handlers{ prefixDb: spdb, - ReplaceSeparator: replaceSeparator, + ReplaceSeparator: mockReplaceSeparator, } mockSyms := []byte("1:SRF\n2:MILO")