@@ -20,45 +20,41 @@ var _ = Describe("When I use hoverctl", func() {
20
20
proxyPort = strconv .Itoa (freeport .GetPort ())
21
21
)
22
22
23
- Context ("I can get the logs using the log command" , func () {
23
+ BeforeEach (func () {
24
+ WriteConfiguration ("localhost" , adminPort , proxyPort )
25
+ })
24
26
25
- BeforeEach (func () {
26
- exec .Command (hoverctlBinary , "start" , "--admin-port=" + adminPort , "--proxy-port=" + proxyPort ).Output ()
27
- WriteConfiguration ("localhost" , adminPort , proxyPort )
28
- })
27
+ AfterEach (func () {
28
+ exec .Command (hoverctlBinary , "stop" , "--admin-port=" + adminPort , "--proxy-port=" + proxyPort ).Output ()
29
+ })
29
30
30
- AfterEach (func () {
31
- exec .Command (hoverctlBinary , "stop" , "--admin-port=" + adminPort , "--proxy-port=" + proxyPort ).Output ()
32
- })
31
+ Context ("I can get the logs using the log command" , func () {
33
32
34
33
It ("should return the logs" , func () {
34
+ exec .Command (hoverctlBinary , "start" , "--admin-port=" + adminPort , "--proxy-port=" + proxyPort ).Output ()
35
+
35
36
out , _ := exec .Command (hoverctlBinary , "logs" , "--admin-port=" + adminPort , "--proxy-port=" + proxyPort ).Output ()
36
37
37
38
output := strings .TrimSpace (string (out ))
38
39
Expect (output ).To (ContainSubstring ("listening on :" + adminPort ))
39
40
})
40
41
41
42
It ("should return an error if the logs don't exist" , func () {
43
+ exec .Command (hoverctlBinary , "start" , "--admin-port=" + adminPort , "--proxy-port=" + proxyPort ).Output ()
44
+
42
45
out , _ := exec .Command (hoverctlBinary , "logs" , "--admin-port=hotdogs" , "--proxy-port=burgers" ).Output ()
43
46
44
47
output := strings .TrimSpace (string (out ))
45
48
Expect (output ).To (ContainSubstring ("Could not open Hoverfly log file" ))
46
49
})
47
50
})
48
51
49
- Describe ("and start Hoverfly using hoverctl" , func () {
52
+ Context ("and start Hoverfly using hoverctl" , func () {
50
53
51
54
Context ("the logs get captured in a .log file" , func () {
52
- BeforeEach ( func () {
55
+ It ( "and I can see it has started" , func () {
53
56
exec .Command (hoverctlBinary , "start" , "--admin-port=" + adminPort , "--proxy-port=" + proxyPort ).Output ()
54
- WriteConfiguration ("localhost" , adminPort , proxyPort )
55
- })
56
-
57
- AfterEach (func () {
58
- exec .Command (hoverctlBinary , "stop" , "--admin-port=" + adminPort , "--proxy-port=" + proxyPort ).Output ()
59
- })
60
57
61
- It ("and I can see it has started" , func () {
62
58
workingDir , _ := os .Getwd ()
63
59
filePath := filepath .Join (workingDir , ".hoverfly/" , "hoverfly." + adminPort + "." + proxyPort + ".log" )
64
60
@@ -69,6 +65,7 @@ var _ = Describe("When I use hoverctl", func() {
69
65
})
70
66
71
67
It ("and they get updated when you use hoverfly" , func () {
68
+ exec .Command (hoverctlBinary , "start" , "--admin-port=" + adminPort , "--proxy-port=" + proxyPort ).Output ()
72
69
73
70
adminPortAsString , _ := strconv .Atoi (adminPort )
74
71
@@ -85,6 +82,8 @@ var _ = Describe("When I use hoverctl", func() {
85
82
})
86
83
87
84
It ("and the stderr is captured in the log file" , func () {
85
+ exec .Command (hoverctlBinary , "start" , "--admin-port=" + adminPort , "--proxy-port=" + proxyPort ).Output ()
86
+
88
87
req := sling .New ().Post (fmt .Sprintf ("http://localhost:%v/api/state" , adminPort )).Body (strings .NewReader (`{"mode":"not-a-mode"}` ))
89
88
DoRequest (req )
90
89
0 commit comments