add tags to toggle between online and offline tests

This commit is contained in:
Carlosokumu 2024-10-05 21:47:17 +03:00
parent 86ba03b375
commit 2703e6d1df
Signed by: carlos
GPG Key ID: 7BD6BC8160A5C953
3 changed files with 18 additions and 3 deletions

View File

@ -1,4 +1,4 @@
package enginetest package engine
import ( import (
"context" "context"
@ -22,6 +22,7 @@ var (
) )
func TestEngine(sessionId string) (engine.Engine, func()) { func TestEngine(sessionId string) (engine.Engine, func()) {
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,8 +77,12 @@ func TestEngine(sessionId string) (engine.Engine, func()) {
os.Exit(1) os.Exit(1)
} }
mockAccountService := server.MockAccountService{} if OnlineTestEnabled {
hl, err := lhs.GetHandler(&mockAccountService) 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)

5
engine/tag_offline.go Normal file
View File

@ -0,0 +1,5 @@
// +build !online
package engine
const OnlineTestEnabled = false

5
engine/tag_online.go Normal file
View File

@ -0,0 +1,5 @@
// +build online
package engine
const OnlineTestEnabled = true