-
Notifications
You must be signed in to change notification settings - Fork 43
/
main_suite_test.go
40 lines (34 loc) · 890 Bytes
/
main_suite_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
package main_test
import (
"runtime"
"strings"
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
func TestCommands(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Main Suite")
}
var (
commandPath string
commandName string
)
var _ = SynchronizedBeforeSuite(func() []byte {
executable_path, err := Build("code.cloudfoundry.org/credhub-cli", "-ldflags", "-X code.cloudfoundry.org/credhub-cli/version.Version=test-version")
Expect(err).NotTo(HaveOccurred())
return []byte(executable_path)
}, func(data []byte) {
commandPath = string(data)
commandName = getLeafFileName(commandPath)
})
func getLeafFileName(path string) string {
var pathArray []string
if runtime.GOOS == "windows" {
pathArray = strings.Split(path, "\\")
} else {
pathArray = strings.Split(path, "/")
}
return pathArray[len(pathArray)-1]
}