forked from cyberark/summon-aws-secrets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage_test.go
47 lines (38 loc) · 1 KB
/
package_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
package main
import (
. "github.com/smartystreets/goconvey/convey"
"os"
"testing"
"os/exec"
"bytes"
)
func RunCommand(name string, arg ...string) (bytes.Buffer, bytes.Buffer, error) {
cmd := exec.Command(name, arg...)
var stdout bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err := cmd.Run()
return stdout, stderr, err
}
func WithoutArgs() {
Convey("Given summon-aws-secrets is run with no arguments", func() {
_, stderr, err := RunCommand(PackageName)
Convey("Returns with error", func() {
So(err, ShouldNotBeNil)
So(stderr.String(), ShouldEqual, "A variable name or version flag must be given as the first and only argument!")
})
})
}
const PackageName = "summon-aws-secrets"
func TestPackage(t *testing.T) {
Path := os.Getenv("PATH")
Convey("Given a compiled summon-aws-secrets package", t, func() {
Convey("Given no configuration information", func() {
e := ClearEnv()
defer e.RestoreEnv()
os.Setenv("PATH", Path)
WithoutArgs()
})
})
}