github.com/liamawhite/cli-with-i18n@v6.32.1-0.20171122084555-dede0a5c3448+incompatible/util/configv3/config_suite_test.go (about)

     1  package configv3_test
     2  
     3  import (
     4  	"io/ioutil"
     5  	"os"
     6  	"path/filepath"
     7  
     8  	"github.com/liamawhite/cli-with-i18n/integration/helpers"
     9  	. "github.com/onsi/ginkgo"
    10  	. "github.com/onsi/gomega"
    11  
    12  	"testing"
    13  )
    14  
    15  func TestConfig(t *testing.T) {
    16  	RegisterFailHandler(Fail)
    17  	RunSpecs(t, "Config Suite")
    18  }
    19  
    20  func setup() string {
    21  	homeDir, err := ioutil.TempDir("", "cli-config-tests")
    22  	Expect(err).NotTo(HaveOccurred())
    23  	err = os.Setenv("CF_HOME", homeDir)
    24  	Expect(err).NotTo(HaveOccurred())
    25  	return homeDir
    26  }
    27  
    28  func teardown(homeDir string) {
    29  	if homeDir != "" {
    30  		err := os.RemoveAll(homeDir)
    31  		Expect(err).ToNot(HaveOccurred())
    32  		err = os.Unsetenv("CF_HOME")
    33  		Expect(err).ToNot(HaveOccurred())
    34  	}
    35  }
    36  
    37  func setConfig(homeDir string, rawConfig string) {
    38  	helpers.SetConfigContent(filepath.Join(homeDir, ".cf"), rawConfig)
    39  }
    40  
    41  func setPluginConfig(pluginDir string, rawConfig string) {
    42  	helpers.SetConfigContent(pluginDir, rawConfig)
    43  }