forked from cloudfoundry/route-registrar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
55 lines (43 loc) · 1.05 KB
/
main_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
53
54
55
package main_test
import (
"fmt"
"os/exec"
"strconv"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
)
var _ = Describe("Main", func() {
var natsCmd *exec.Cmd
BeforeEach(func() {
initConfig()
writeConfig()
natsCmd = exec.Command(
"gnatsd",
"-p", strconv.Itoa(natsPort),
"--user", "nats",
"--pass", "nats")
err := natsCmd.Start()
Ω(err).NotTo(HaveOccurred())
})
AfterEach(func() {
natsCmd.Process.Kill()
natsCmd.Wait()
})
It("Starts correctly and exits 1 on SIGTERM", func() {
command := exec.Command(
routeRegistrarBinPath,
fmt.Sprintf("-pidfile=%s", pidFile),
fmt.Sprintf("-configPath=%s", configFile),
fmt.Sprintf("-scriptPath=%s", scriptPath),
)
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Ω(err).ShouldNot(HaveOccurred())
Eventually(session.Out).Should(gbytes.Say("Route Registrar"))
time.Sleep(500 * time.Millisecond)
session.Terminate().Wait()
Eventually(session).Should(gexec.Exit(1))
})
})