forked from cloud66-oss/starter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli_test.go
52 lines (45 loc) · 1.33 KB
/
cli_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
50
51
52
package main_test
import (
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"os/exec"
"time"
)
var helpText string
var versionText string
var _ = Describe("Running Starter", func() {
BeforeEach(func() {
version := "test"
current_date := time.Now().Format("2006-01-02")
helpText = fmt.Sprintf("Starter (%s) Help\n", version)
versionText = fmt.Sprintf("Starter version: %s (%s)\n", version, current_date)
})
Context("using the help flag", func() {
It("should show the help", func() {
command := exec.Command(binPath, "help")
command_out, err := command.Output()
output_string := string(command_out)
Expect(string(output_string)).To(Equal(helpText))
Expect(err).NotTo(HaveOccurred())
})
})
Context("using the version flag", func() {
It("should show the version", func() {
command := exec.Command(binPath, "version")
command_out, err := command.Output()
output_string := string(command_out)
Expect(string(output_string)).To(Equal(versionText))
Expect(err).NotTo(HaveOccurred())
})
})
Context("using the -v flag", func() {
It("should show the version", func() {
command := exec.Command(binPath, "-v")
command_out, err := command.Output()
output_string := string(command_out)
Expect(string(output_string)).To(Equal(versionText))
Expect(err).NotTo(HaveOccurred())
})
})
})