update account service initialization based on the tag

This commit is contained in:
Carlosokumu 2024-10-08 22:43:11 +03:00
parent 8751c4f5bd
commit 22047ba703
Signed by: carlos
GPG Key ID: 7BD6BC8160A5C953
3 changed files with 22 additions and 11 deletions

View File

@ -10,7 +10,6 @@ import (
"git.defalsify.org/vise.git/logging" "git.defalsify.org/vise.git/logging"
"git.defalsify.org/vise.git/resource" "git.defalsify.org/vise.git/resource"
"git.grassecon.net/urdt/ussd/internal/handlers" "git.grassecon.net/urdt/ussd/internal/handlers"
"git.grassecon.net/urdt/ussd/internal/handlers/server"
"git.grassecon.net/urdt/ussd/internal/storage" "git.grassecon.net/urdt/ussd/internal/storage"
testdataloader "github.com/peteole/testdata-loader" testdataloader "github.com/peteole/testdata-loader"
) )
@ -22,7 +21,7 @@ var (
) )
func TestEngine(sessionId string) (engine.Engine, func()) { func TestEngine(sessionId string) (engine.Engine, func()) {
var accountService server.AccountServiceInterface //var accountService server.AccountServiceInterface
ctx := context.Background() ctx := context.Background()
ctx = context.WithValue(ctx, "SessionId", sessionId) ctx = context.WithValue(ctx, "SessionId", sessionId)
pfp := path.Join(scriptDir, "pp.csv") pfp := path.Join(scriptDir, "pp.csv")
@ -76,13 +75,7 @@ func TestEngine(sessionId string) (engine.Engine, func()) {
fmt.Fprintf(os.Stderr, err.Error()) fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1) os.Exit(1)
} }
hl, err := lhs.GetHandler(AccountService)
if OnlineTestEnabled {
accountService = &server.AccountService{}
} else {
accountService = &server.MockAccountService{}
}
hl, err := lhs.GetHandler(accountService)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, err.Error()) fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1) os.Exit(1)

View File

@ -2,4 +2,12 @@
package testutil package testutil
const OnlineTestEnabled = false import (
"git.grassecon.net/urdt/ussd/internal/handlers/server"
)
var AccountService server.AccountServiceInterface
func init() {
AccountService = &server.MockAccountService{}
}

View File

@ -3,3 +3,13 @@
package testutil package testutil
const OnlineTestEnabled = true const OnlineTestEnabled = true
var AccountService server.AccountServiceInterface
func init() {
AccountService = &server.AccountService{}
}