Make the mocking of Google API configurable in unit tests
This commit is contained in:
		@@ -4,6 +4,7 @@ import (
 | 
			
		||||
	"testing"
 | 
			
		||||
	"."
 | 
			
		||||
	"reflect"
 | 
			
		||||
	"os"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -77,8 +78,10 @@ méltányosság
 | 
			
		||||
 | 
			
		||||
	for _, data := range cases {
 | 
			
		||||
		j := trans.New(data.job[0], data.job[1], data.job[2])
 | 
			
		||||
		j.Translator = func(t *trans.Translation) (string, error) {
 | 
			
		||||
			return data.transOutput, nil
 | 
			
		||||
		if _, ok := os.LookupEnv("NOMOCK"); !ok {
 | 
			
		||||
			j.Translator = func(t *trans.Translation) (string, error) {
 | 
			
		||||
				return data.transOutput, nil
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		r := j.Translate()
 | 
			
		||||
		if (!reflect.DeepEqual(r, data.expectedResults)) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user