github.com/gobuffalo/buffalo-cli/v2@v2.0.0-alpha.15.0.20200919213536-a7350c8e6799/cli/cmds/test/go_env_test.go (about)

     1  package test
     2  
     3  import (
     4  	"context"
     5  	"os"
     6  	"testing"
     7  )
     8  
     9  func Test_GoEnv(t *testing.T) {
    10  	goEnv := &GoEnv{}
    11  
    12  	os.Setenv("GO_ENV", "Antonio's Home")
    13  
    14  	err := goEnv.BeforeTest(context.Background(), "", []string{})
    15  	if err != nil {
    16  		t.Error("error setting GO_ENV")
    17  	}
    18  
    19  	if os.Getenv("GO_ENV") != "test" {
    20  		t.Error("GO_ENV should be set to be test")
    21  	}
    22  
    23  	err = goEnv.AfterTest(context.Background(), "", []string{}, nil)
    24  	if err != nil {
    25  		t.Error("error setting GO_ENV")
    26  	}
    27  
    28  	if os.Getenv("GO_ENV") != "Antonio's Home" {
    29  		t.Error("GO_ENV should be set to be blank")
    30  	}
    31  }