From 22047ba70333a93651698f33e0270362c763e6b3 Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Tue, 8 Oct 2024 22:43:11 +0300 Subject: [PATCH] update account service initialization based on the tag --- internal/testutil/TestEngine.go | 11 ++--------- internal/testutil/tag_offline.go | 10 +++++++++- internal/testutil/tag_online.go | 12 +++++++++++- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/internal/testutil/TestEngine.go b/internal/testutil/TestEngine.go index 3241f7c..e7320f3 100644 --- a/internal/testutil/TestEngine.go +++ b/internal/testutil/TestEngine.go @@ -10,7 +10,6 @@ import ( "git.defalsify.org/vise.git/logging" "git.defalsify.org/vise.git/resource" "git.grassecon.net/urdt/ussd/internal/handlers" - "git.grassecon.net/urdt/ussd/internal/handlers/server" "git.grassecon.net/urdt/ussd/internal/storage" testdataloader "github.com/peteole/testdata-loader" ) @@ -22,7 +21,7 @@ var ( ) func TestEngine(sessionId string) (engine.Engine, func()) { - var accountService server.AccountServiceInterface + //var accountService server.AccountServiceInterface ctx := context.Background() ctx = context.WithValue(ctx, "SessionId", sessionId) pfp := path.Join(scriptDir, "pp.csv") @@ -76,13 +75,7 @@ func TestEngine(sessionId string) (engine.Engine, func()) { fmt.Fprintf(os.Stderr, err.Error()) os.Exit(1) } - - if OnlineTestEnabled { - accountService = &server.AccountService{} - } else { - accountService = &server.MockAccountService{} - } - hl, err := lhs.GetHandler(accountService) + hl, err := lhs.GetHandler(AccountService) if err != nil { fmt.Fprintf(os.Stderr, err.Error()) os.Exit(1) diff --git a/internal/testutil/tag_offline.go b/internal/testutil/tag_offline.go index ea97f52..0cdfd0f 100644 --- a/internal/testutil/tag_offline.go +++ b/internal/testutil/tag_offline.go @@ -2,4 +2,12 @@ package testutil -const OnlineTestEnabled = false \ No newline at end of file +import ( + "git.grassecon.net/urdt/ussd/internal/handlers/server" +) + +var AccountService server.AccountServiceInterface + +func init() { + AccountService = &server.MockAccountService{} +} diff --git a/internal/testutil/tag_online.go b/internal/testutil/tag_online.go index 6a953fa..434f36d 100644 --- a/internal/testutil/tag_online.go +++ b/internal/testutil/tag_online.go @@ -2,4 +2,14 @@ package testutil -const OnlineTestEnabled = true \ No newline at end of file +const OnlineTestEnabled = true + + + + +var AccountService server.AccountServiceInterface + + +func init() { + AccountService = &server.AccountService{} +} \ No newline at end of file