From d181c3494618c3c3ffce6336ef8ada05b487ebb9 Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Thu, 17 Oct 2024 12:49:28 +0300 Subject: [PATCH] update handler and move transaction struct to models --- internal/handlers/ussd/menuhandler_test.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/internal/handlers/ussd/menuhandler_test.go b/internal/handlers/ussd/menuhandler_test.go index 0bde51a..38c468c 100644 --- a/internal/handlers/ussd/menuhandler_test.go +++ b/internal/handlers/ussd/menuhandler_test.go @@ -15,6 +15,7 @@ import ( "git.defalsify.org/vise.git/persist" "git.defalsify.org/vise.git/resource" "git.defalsify.org/vise.git/state" + "git.grassecon.net/urdt/ussd/internal/handlers/server" "git.grassecon.net/urdt/ussd/internal/mocks" "git.grassecon.net/urdt/ussd/internal/models" "git.grassecon.net/urdt/ussd/internal/utils" @@ -28,22 +29,15 @@ var ( flagsPath = path.Join(baseDir, "services", "registration", "pp.csv") ) -type Transaction struct { - CreatedAt time.Time `json:"createdAt"` - Status string `json:"status"` - TransferValue json.Number `json:"transferValue"` - TxHash string `json:"txHash"` - TxType string `json:"txType"` -} - func TestNewHandlers(t *testing.T) { fm, err := NewFlagManager(flagsPath) + accountService := server.TestAccountService{} if err != nil { t.Logf(err.Error()) } t.Run("Valid UserDataStore", func(t *testing.T) { mockStore := &mocks.MockUserDataStore{} - handlers, err := NewHandlers(fm.parser, mockStore) + handlers, err := NewHandlers(fm.parser, mockStore, &accountService) if err != nil { t.Fatalf("expected no error, got %v", err) } @@ -59,7 +53,7 @@ func TestNewHandlers(t *testing.T) { t.Run("Nil UserDataStore", func(t *testing.T) { appFlags := &asm.FlagParser{} - handlers, err := NewHandlers(appFlags, nil) + handlers, err := NewHandlers(appFlags, nil, &accountService) if err == nil { t.Fatal("expected an error, got none") @@ -1089,7 +1083,7 @@ func TestCheckAccountStatus(t *testing.T) { TxType string "json:\"txType\"" } }{ - Transaction: Transaction{ + Transaction: models.Transaction{ CreatedAt: time.Now(), Status: "SUCCESS", TransferValue: json.Number("0.5"), @@ -1127,7 +1121,7 @@ func TestCheckAccountStatus(t *testing.T) { TxType string "json:\"txType\"" } }{ - Transaction: Transaction{ + Transaction: models.Transaction{ CreatedAt: time.Now(), Status: "IN_NETWORK", TransferValue: json.Number("0.5"),