Skip to content

Commit

Permalink
add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kapishmalik authored and tommysitu committed Mar 13, 2024
1 parent bec201e commit d6ce5a0
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/matching/matchers/negation_match.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package matchers

var Negation = "negation"
var Negation = "negate"

func NegationMatch(match interface{}, toMatch string) bool {
matchString, ok := match.(string)
Expand Down
26 changes: 26 additions & 0 deletions functional-tests/core/ft_simulation_matching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,30 @@ var _ = Describe(" When using different matchers", func() {
})

})

Context("Using negate match", func() {

BeforeEach(func() {
hoverfly.ImportSimulation(testdata.NegationMatch)
})

It("path should not match with different path passed", func() {
req := sling.New().Get("http://test.com/path2")

response := hoverfly.Proxy(req)
Expect(response.StatusCode).To(Equal(200))

Expect(io.ReadAll(response.Body)).Should(Equal([]byte("destination matched")))
})

It("path should not match with no path passed", func() {
req := sling.New().Get("http://test.com")

response := hoverfly.Proxy(req)
Expect(response.StatusCode).To(Equal(200))

Expect(io.ReadAll(response.Body)).Should(Equal([]byte("destination matched")))
})

})
})
68 changes: 68 additions & 0 deletions functional-tests/testdata/negation_match.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package testdata

var NegationMatch = `{
"data": {
"pairs": [
{
"request": {
"path": [
{
"matcher": "negate",
"value": "/path1"
}
],
"method": [
{
"matcher": "exact",
"value": "GET"
}
],
"destination": [
{
"matcher": "exact",
"value": "test.com"
}
],
"scheme": [
{
"matcher": "exact",
"value": "http"
}
],
"deprecatedQuery": [
{
"matcher": "exact",
"value": ""
}
],
"body": [
{
"matcher": "exact",
"value": ""
}
]
},
"response": {
"status": 200,
"body": "destination matched",
"encodedBody": false,
"headers": {
"Header": [
"value1"
]
},
"templated": false
}
}
],
"globalActions": {
"delays": [],
"delaysLogNormal": []
}
},
"meta": {
"schemaVersion": "v5",
"hoverflyVersion": "v0.17.0",
"timeExported": "2018-05-03T12:12:46+01:00"
}
}`

0 comments on commit d6ce5a0

Please sign in to comment.