-
Notifications
You must be signed in to change notification settings - Fork 30
/
spawn_test.go
49 lines (43 loc) · 933 Bytes
/
spawn_test.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
package main
import (
"strings"
"testing"
"github.com/miquella/vaulted/lib"
)
func TestSpawn(t *testing.T) {
spawnRefreshVar := `GOPATH="/vaulted"`
store := NewTestStore()
store.Vaults["one"] = &vaulted.Vault{}
store.Vaults["one"].Vars = map[string]string{
"GOPATH": "/vaulted",
}
CaptureStdout(func() {
s := Spawn{
SessionOptions: SessionOptions{
VaultName: "one",
},
Command: []string{"go", "version"},
}
err := s.Run(store)
if err != nil {
t.Fatal(err)
}
})
output := CaptureStdout(func() {
s := Spawn{
SessionOptions: SessionOptions{
VaultName: "one",
Refresh: true,
},
Command: []string{"go", "env"},
DisplayStatus: true,
}
err := s.Run(store)
if err != nil {
t.Fatal(err)
}
})
if !strings.Contains(string(output), spawnRefreshVar) {
t.Errorf("Incorrect output!\nExpected to contain:\n\"%s\"\ngot:\n\"%s\"", spawnRefreshVar, output)
}
}