forked from grassrootseconomics/visedriver
		
	add tags to toggle between online and offline tests
This commit is contained in:
		
							parent
							
								
									86ba03b375
								
							
						
					
					
						commit
						2703e6d1df
					
				@ -1,4 +1,4 @@
 | 
			
		||||
package enginetest
 | 
			
		||||
package engine
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
@ -22,6 +22,7 @@ var (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestEngine(sessionId string) (engine.Engine, func()) {
 | 
			
		||||
	var accountService server.AccountServiceInterface
 | 
			
		||||
	ctx := context.Background()
 | 
			
		||||
	ctx = context.WithValue(ctx, "SessionId", sessionId)
 | 
			
		||||
	pfp := path.Join(scriptDir, "pp.csv")
 | 
			
		||||
@ -76,8 +77,12 @@ func TestEngine(sessionId string) (engine.Engine, func()) {
 | 
			
		||||
		os.Exit(1)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	mockAccountService := server.MockAccountService{}
 | 
			
		||||
	hl, err := lhs.GetHandler(&mockAccountService)
 | 
			
		||||
	if OnlineTestEnabled {
 | 
			
		||||
		accountService = &server.AccountService{}
 | 
			
		||||
	} else {
 | 
			
		||||
		accountService = &server.MockAccountService{}
 | 
			
		||||
	}
 | 
			
		||||
	hl, err := lhs.GetHandler(accountService)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		fmt.Fprintf(os.Stderr, err.Error())
 | 
			
		||||
		os.Exit(1)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										5
									
								
								engine/tag_offline.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								engine/tag_offline.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
// +build !online
 | 
			
		||||
 | 
			
		||||
package engine
 | 
			
		||||
 | 
			
		||||
const OnlineTestEnabled = false
 | 
			
		||||
							
								
								
									
										5
									
								
								engine/tag_online.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								engine/tag_online.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
			
		||||
// +build online
 | 
			
		||||
 | 
			
		||||
package engine
 | 
			
		||||
 | 
			
		||||
const OnlineTestEnabled = true
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user