Skip to content

Commit ac5bbd7

Browse files
committed
Remove dependency on external remote middleware for testing
1 parent ebc7ef3 commit ac5bbd7

File tree

2 files changed

+27
-79
lines changed

2 files changed

+27
-79
lines changed

functional-tests/hoverctl/middleware_test.go

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
})

functional-tests/testdata/json_get_and_post.go

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -101,78 +101,3 @@ var JsonGetAndPost = `{
101101
}
102102
}`
103103

104-
var V3JsonGetAndPost = `{
105-
"data": {
106-
"pairs": [
107-
{
108-
"response": {
109-
"status": 201,
110-
"body": "body1",
111-
"encodedBody": false,
112-
"headers": {
113-
"Header": [
114-
"value1",
115-
"value2"
116-
]
117-
}
118-
},
119-
"request": {
120-
"path": {
121-
"exactMatch": "/path1"
122-
},
123-
"method": {
124-
"exactMatch": "GET"
125-
},
126-
"destination": {
127-
"exactMatch": "destination1"
128-
},
129-
"scheme": {
130-
"exactMatch": "http"
131-
},
132-
"query": {
133-
"exactMatch": ""
134-
},
135-
"body": {
136-
"exactMatch": ""
137-
}
138-
}
139-
},
140-
{
141-
"response": {
142-
"status": 200,
143-
"body": "POST body response",
144-
"encodedBody": false,
145-
"headers": {}
146-
},
147-
"request": {
148-
"path": {
149-
"exactMatch": "/path2/resource"
150-
},
151-
"method": {
152-
"exactMatch": "POST"
153-
},
154-
"destination": {
155-
"exactMatch": "another-destination.com"
156-
},
157-
"scheme": {
158-
"exactMatch": "http"
159-
},
160-
"query": {
161-
"exactMatch": ""
162-
},
163-
"body": {
164-
"exactMatch": ""
165-
}
166-
}
167-
}
168-
],
169-
"globalActions": {
170-
"delays": []
171-
}
172-
},
173-
"meta": {
174-
"schemaVersion": "v3",
175-
"hoverflyVersion": "v0.10.2",
176-
"timeExported": "2017-02-23T12:43:48Z"
177-
}
178-
}`

0 commit comments

Comments
 (0)