@@ -16,6 +16,7 @@ var _ = Describe("When I use hoverctl", func() {
1616
1717 var (
1818 hoverfly * functional_tests.Hoverfly
19+ remoteMiddleware * functional_tests.Hoverfly
1920 )
2021
2122 Describe ("with a running hoverfly which has middleware configured" , func () {
@@ -30,6 +31,9 @@ var _ = Describe("When I use hoverctl", func() {
3031
3132 AfterEach (func () {
3233 hoverfly .Stop ()
34+ if remoteMiddleware != nil {
35+ remoteMiddleware .Stop ()
36+ }
3337 })
3438
3539 It ("I can get the hoverfly's middleware" , func () {
@@ -122,18 +126,37 @@ var _ = Describe("When I use hoverctl", func() {
122126 Expect (output ).To (ContainSubstring ("Remote: " + middlewareServer .URL ))
123127 })
124128
125- It ("I cannae set the hoverfly's middleware when specifying non-existing file" , func () {
129+ It ("I cannot set the hoverfly's middleware when specifying non-existing file" , func () {
126130 output := functional_tests .Run (hoverctlBinary , "middleware" , "--binary" , "python" , "--script" , "testdata/not_a_real_file.fake" )
127131
128132 Expect (output ).To (ContainSubstring ("File not found: testdata/not_a_real_file.fake" ))
129133 })
130134
131- It ("I cannae set the hoverfly's middleware when specifying non-existing remote middleware" , func () {
132- output := functional_tests .Run (hoverctlBinary , "middleware" , "--remote" , "http://specto-fda13.web.app/404/nothere" )
135+ It ("I cannot set the hoverfly's middleware when specifying non-existing remote middleware" , func () {
136+ remoteMiddleware = functional_tests .NewHoverfly ()
137+ remoteMiddleware .Start ("-webserver" )
138+ remoteMiddleware .SetMode ("simulate" )
139+ remoteMiddleware .ImportSimulation (`{
140+ "data": {
141+ "pairs": [
142+ {
143+ "request": {},
144+ "response": {
145+ "status": 404
146+ }
147+ }
148+ ]
149+ },
150+ "meta": {
151+ "schemaVersion": "v5"
152+ }
153+ }` )
154+
155+ output := functional_tests .Run (hoverctlBinary , "middleware" , "--remote" , "http://localhost:" + remoteMiddleware .GetProxyPort ())
133156
134157 Expect (output ).To (ContainSubstring ("Could not set middleware, it may have failed the test" ))
135158 Expect (output ).To (ContainSubstring ("Error when communicating with remote middleware: received 404" ))
136- Expect (output ).To (ContainSubstring ("URL: http://specto-fda13.web.app/404/nothere " ))
159+ Expect (output ).To (ContainSubstring ("URL: http://localhost " ))
137160 Expect (output ).To (ContainSubstring ("STDIN:" ))
138161 Expect (output ).To (ContainSubstring (`{"response":{"status":200,"body":"ok","encodedBody":false,"headers":{"test_header":["true"]}},"request":{"path":"/","method":"GET","destination":"www.test.com","scheme":"","query":"","formData":null,"body":"","headers":{"test_header":["true"]}}}` ))
139162 })
0 commit comments