Skip to content

Commit

Permalink
use a common mockReplaceSeparator func
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfred-mk committed Dec 18, 2024
1 parent ecfdab4 commit 055c2db
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions internal/handlers/ussd/menuhandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 055c2db

Please sign in to comment.