forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
56 lines (43 loc) · 2.51 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package helpers
import (
"io/ioutil"
"os"
"path/filepath"
"code.cloudfoundry.org/cli/util/configv3"
. "github.com/onsi/gomega"
)
func TurnOffColors() {
Expect(os.Setenv("CF_COLOR", "false")).To(Succeed())
}
func TurnOnExperimental() {
Expect(os.Setenv("CF_CLI_EXPERIMENTAL", "true")).To(Succeed())
}
func SetHomeDir() string {
var err error
homeDir, err := ioutil.TempDir("", "cli-integration-test")
Expect(err).NotTo(HaveOccurred())
Expect(os.Setenv("CF_HOME", homeDir)).To(Succeed())
Expect(os.Setenv("CF_PLUGIN_HOME", homeDir)).To(Succeed())
return homeDir
}
func DestroyHomeDir(homeDir string) {
if homeDir != "" {
Expect(os.RemoveAll(homeDir)).To(Succeed())
}
}
func SetConfig(cb func(conf *configv3.Config)) {
config, err := configv3.LoadConfig()
Expect(err).ToNot(HaveOccurred())
cb(config)
err = configv3.WriteConfig(config)
Expect(err).ToNot(HaveOccurred())
}
func SetConfigContent(dir string, rawConfig string) {
err := os.MkdirAll(filepath.Join(dir), 0777)
Expect(err).ToNot(HaveOccurred())
err = ioutil.WriteFile(filepath.Join(dir, "config.json"), []byte(rawConfig), 0644)
Expect(err).ToNot(HaveOccurred())
}
func InvalidAccessToken() string {
return "bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImxlZ2FjeS10b2tlbi1rZXkiLCJ0eXAiOiJKV1QifQ.eyJqdGkiOiJiMjZmMTFjMWNhYmI0ZmY0ODhlN2RhYTJkZTQxMTA4NiIsInN1YiI6IjBjZWMwY2E4LTA5MmYtNDkzYy1hYmExLWM4ZTZiMTRiODM3NiIsInNjb3BlIjpbIm9wZW5pZCIsInJvd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