menu-traversal-v2 #115

Merged
lash merged 15 commits from menu-traversal-v2 into master 2024-10-18 15:38:56 +02:00
Showing only changes of commit d181c34946 - Show all commits

View File

@ -15,6 +15,7 @@ import (
"git.defalsify.org/vise.git/persist" "git.defalsify.org/vise.git/persist"
"git.defalsify.org/vise.git/resource" "git.defalsify.org/vise.git/resource"
"git.defalsify.org/vise.git/state" "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/mocks"
"git.grassecon.net/urdt/ussd/internal/models" "git.grassecon.net/urdt/ussd/internal/models"
"git.grassecon.net/urdt/ussd/internal/utils" "git.grassecon.net/urdt/ussd/internal/utils"
@ -28,22 +29,15 @@ var (
flagsPath = path.Join(baseDir, "services", "registration", "pp.csv") 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) { func TestNewHandlers(t *testing.T) {
fm, err := NewFlagManager(flagsPath) fm, err := NewFlagManager(flagsPath)
accountService := server.TestAccountService{}
if err != nil { if err != nil {
t.Logf(err.Error()) t.Logf(err.Error())
} }
t.Run("Valid UserDataStore", func(t *testing.T) { t.Run("Valid UserDataStore", func(t *testing.T) {
mockStore := &mocks.MockUserDataStore{} mockStore := &mocks.MockUserDataStore{}
handlers, err := NewHandlers(fm.parser, mockStore) handlers, err := NewHandlers(fm.parser, mockStore, &accountService)
if err != nil { if err != nil {
t.Fatalf("expected no error, got %v", err) 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) { t.Run("Nil UserDataStore", func(t *testing.T) {
appFlags := &asm.FlagParser{} appFlags := &asm.FlagParser{}
handlers, err := NewHandlers(appFlags, nil) handlers, err := NewHandlers(appFlags, nil, &accountService)
if err == nil { if err == nil {
t.Fatal("expected an error, got none") t.Fatal("expected an error, got none")
@ -1089,7 +1083,7 @@ func TestCheckAccountStatus(t *testing.T) {
TxType string "json:\"txType\"" TxType string "json:\"txType\""
} }
}{ }{
Transaction: Transaction{ Transaction: models.Transaction{
CreatedAt: time.Now(), CreatedAt: time.Now(),
Status: "SUCCESS", Status: "SUCCESS",
TransferValue: json.Number("0.5"), TransferValue: json.Number("0.5"),
@ -1127,7 +1121,7 @@ func TestCheckAccountStatus(t *testing.T) {
TxType string "json:\"txType\"" TxType string "json:\"txType\""
} }
}{ }{
Transaction: Transaction{ Transaction: models.Transaction{
CreatedAt: time.Now(), CreatedAt: time.Now(),
Status: "IN_NETWORK", Status: "IN_NETWORK",
TransferValue: json.Number("0.5"), TransferValue: json.Number("0.5"),