forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command.go
47 lines (41 loc) · 1.06 KB
/
command.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
package helpers
import (
"io"
"os"
"os/exec"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
func CF(args ...string) *Session {
session, err := Start(
exec.Command("cf", args...),
NewPrefixedWriter("OUT: ", GinkgoWriter),
NewPrefixedWriter("ERR: ", GinkgoWriter))
Expect(err).NotTo(HaveOccurred())
return session
}
func CFWithStdin(stdin io.Reader, args ...string) *Session {
command := exec.Command("cf", args...)
command.Stdin = stdin
session, err := Start(
command,
NewPrefixedWriter("OUT: ", GinkgoWriter),
NewPrefixedWriter("ERR: ", GinkgoWriter))
Expect(err).NotTo(HaveOccurred())
return session
}
func CFWithEnv(envVars map[string]string, args ...string) *Session {
env := os.Environ()
for key, val := range envVars {
env = AddOrReplaceEnvironment(env, key, val)
}
command := exec.Command("cf", args...)
command.Env = env
session, err := Start(
command,
NewPrefixedWriter("OUT: ", GinkgoWriter),
NewPrefixedWriter("ERR: ", GinkgoWriter))
Expect(err).NotTo(HaveOccurred())
return session
}