Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add labels to request response pair #1135

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Upgrade simulation schema version to v5.3
tommysitu committed Jul 11, 2024
commit 375a623fb65622dfefb169a0a18e76262ba5e0f4
2 changes: 1 addition & 1 deletion core/handlers/v2/simulation_views.go
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@ type MetaView struct {
func NewMetaView(version string) *MetaView {
return &MetaView{
HoverflyVersion: version,
SchemaVersion: "v5.2",
SchemaVersion: "v5.3",
TimeExported: time.Now().Format(time.RFC3339),
}
}
6 changes: 3 additions & 3 deletions core/handlers/v2/simulation_views_test.go
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ func Test_NewSimulationViewFromRequestBody_CanCreateSimulationFromV3Payload(t *t
Expect(simulation.GlobalActions.DelaysLogNormal[0].Mean).To(Equal(3))
Expect(simulation.GlobalActions.DelaysLogNormal[0].Median).To(Equal(2))

Expect(simulation.SchemaVersion).To(Equal("v5.2"))
Expect(simulation.SchemaVersion).To(Equal("v5.3"))
Expect(simulation.HoverflyVersion).To(Equal("v0.11.0"))
Expect(simulation.TimeExported).To(Equal("2017-02-23T12:43:48Z"))
}
@@ -135,7 +135,7 @@ func Test_NewSimulationViewFromRequestBody_CanCreateSimulationFromV2Payload(t *t
Expect(simulation.GlobalActions.DelaysLogNormal[0].Mean).To(Equal(3))
Expect(simulation.GlobalActions.DelaysLogNormal[0].Median).To(Equal(2))

Expect(simulation.SchemaVersion).To(Equal("v5.2"))
Expect(simulation.SchemaVersion).To(Equal("v5.3"))
Expect(simulation.HoverflyVersion).To(Equal("v0.11.0"))
Expect(simulation.TimeExported).To(Equal("2017-02-23T12:43:48Z"))
}
@@ -227,7 +227,7 @@ func Test_NewSimulationViewFromRequestBody_CanCreateSimulationFromV1Payload(t *t
Expect(simulation.RequestResponsePairs[0].Response.Status).To(Equal(200))
Expect(simulation.RequestResponsePairs[0].Response.Templated).To(BeFalse())

Expect(simulation.SchemaVersion).To(Equal("v5.2"))
Expect(simulation.SchemaVersion).To(Equal("v5.3"))
Expect(simulation.HoverflyVersion).To(Equal("v0.11.0"))
Expect(simulation.TimeExported).To(Equal("2017-02-23T12:43:48Z"))
}
2 changes: 1 addition & 1 deletion core/handlers/v2/simulation_views_upgrade.go
Original file line number Diff line number Diff line change
@@ -359,7 +359,7 @@ func v2GetMatchersFromRequestFieldMatchersView(requestFieldMatchers *RequestFiel

func newMetaView(originalMeta MetaView) MetaView {
return MetaView{
SchemaVersion: "v5.2",
SchemaVersion: "v5.3",
HoverflyVersion: originalMeta.HoverflyVersion,
TimeExported: originalMeta.TimeExported,
}
6 changes: 3 additions & 3 deletions core/handlers/v2/simulation_views_upgrade_test.go
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ func Test_upgradeV1_ReturnsAnUpgradedSimulation(t *testing.T) {
Expect(upgradedSimulation.RequestResponsePairs[0].Response.EncodedBody).To(BeFalse())
Expect(upgradedSimulation.RequestResponsePairs[0].Response.Headers).To(HaveKeyWithValue("Test", []string{"headers"}))

Expect(upgradedSimulation.SchemaVersion).To(Equal("v5.2"))
Expect(upgradedSimulation.SchemaVersion).To(Equal("v5.3"))
Expect(upgradedSimulation.HoverflyVersion).To(Equal("test"))
Expect(upgradedSimulation.TimeExported).To(Equal("today"))
}
@@ -299,7 +299,7 @@ func Test_upgradeV2_ReturnsAnUpgradedSimulation(t *testing.T) {
Expect(upgradedSimulation.RequestResponsePairs[0].Response.EncodedBody).To(BeFalse())
Expect(upgradedSimulation.RequestResponsePairs[0].Response.Headers).To(HaveKeyWithValue("Test", []string{"headers"}))

Expect(upgradedSimulation.SchemaVersion).To(Equal("v5.2"))
Expect(upgradedSimulation.SchemaVersion).To(Equal("v5.3"))
Expect(upgradedSimulation.HoverflyVersion).To(Equal("test"))
Expect(upgradedSimulation.TimeExported).To(Equal("today"))
}
@@ -507,7 +507,7 @@ func Test_upgradeV4_ReturnsAnUpgradedSimulation(t *testing.T) {
Expect(upgradedSimulation.RequestResponsePairs[0].Response.EncodedBody).To(BeFalse())
Expect(upgradedSimulation.RequestResponsePairs[0].Response.Headers).To(HaveKeyWithValue("Test", []string{"headers"}))

Expect(upgradedSimulation.SchemaVersion).To(Equal("v5.2"))
Expect(upgradedSimulation.SchemaVersion).To(Equal("v5.3"))
Expect(upgradedSimulation.HoverflyVersion).To(Equal("test"))
Expect(upgradedSimulation.TimeExported).To(Equal("today"))
}
4 changes: 2 additions & 2 deletions core/hoverfly_service_test.go
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ func Test_Hoverfly_GetSimulation_ReturnsBlankSimulation_ifThereIsNoData(t *testi
Expect(simulation.RequestResponsePairs).To(HaveLen(0))
Expect(simulation.GlobalActions.Delays).To(HaveLen(0))

Expect(simulation.MetaView.SchemaVersion).To(Equal("v5.2"))
Expect(simulation.MetaView.SchemaVersion).To(Equal("v5.3"))
Expect(simulation.MetaView.HoverflyVersion).To(MatchRegexp(`v\d+.\d+.\d+(-rc.\d)*`))
Expect(simulation.MetaView.TimeExported).ToNot(BeNil())
}
@@ -423,7 +423,7 @@ func Test_Hoverfly_GetFilteredSimulation_ReturnBlankSimulation_IfThereIsNoMatch(
Expect(simulation.GlobalActions.Delays).To(HaveLen(0))
Expect(simulation.GlobalActions.DelaysLogNormal).To(HaveLen(0))

Expect(simulation.MetaView.SchemaVersion).To(Equal("v5.2"))
Expect(simulation.MetaView.SchemaVersion).To(Equal("v5.3"))
Expect(simulation.MetaView.HoverflyVersion).To(MatchRegexp(`v\d+.\d+.\d+(-rc.\d)*`))
Expect(simulation.MetaView.TimeExported).ToNot(BeNil())
}
4 changes: 2 additions & 2 deletions functional-tests/core/api/simulation_api_v2_test.go
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ var _ = Describe("/api/v2/simulation", func() {
Expect(err).To(BeNil())
schemaVersion, err := metaObject.GetString("schemaVersion")
Expect(err).To(BeNil())
Expect(schemaVersion).To(Equal("v5.2"))
Expect(schemaVersion).To(Equal("v5.3"))
hoverflyVersion, err := metaObject.GetString("hoverflyVersion")
Expect(err).To(BeNil())
Expect(hoverflyVersion).ToNot(BeNil())
@@ -173,7 +173,7 @@ var _ = Describe("/api/v2/simulation", func() {
Expect(err).To(BeNil())
schemaVersion, err := metaObject.GetString("schemaVersion")
Expect(err).To(BeNil())
Expect(schemaVersion).To(Equal("v5.2"))
Expect(schemaVersion).To(Equal("v5.3"))
hoverflyVersion, err := metaObject.GetString("hoverflyVersion")
Expect(err).To(BeNil())
Expect(hoverflyVersion).ToNot(BeNil())
2 changes: 1 addition & 1 deletion functional-tests/hoverctl/import_export_test.go
Original file line number Diff line number Diff line change
@@ -188,7 +188,7 @@ var _ = Describe("When I use hoverctl", func() {

hoverflySimulation = `"pairs":[{"labels":["create","bookings"],"request":{"path":[{"matcher":"exact","value":"/api/bookings"}],"method":[{"matcher":"exact","value":"POST"}],"destination":[{"matcher":"exact","value":"www.my-test.com"}],"scheme":[{"matcher":"exact","value":"http"}],"body":[{"matcher":"exact","value":"{\"flightId\": \"1\"}"}],"headers":{"Content-Type":[{"matcher":"exact","value":"application/json"}]}},"response":{"status":201,"body":"","encodedBody":false,"headers":{"Location":["http://localhost/api/bookings/1"]},"templated":false}}],"globalActions":{"delays":[],"delaysLogNormal":[]}}`

hoverflyMeta = `"meta":{"schemaVersion":"v5.2","hoverflyVersion":"v\d+.\d+.\d+(-rc.\d)*","timeExported":`
hoverflyMeta = `"meta":{"schemaVersion":"v5.3","hoverflyVersion":"v\d+.\d+.\d+(-rc.\d)*","timeExported":`
)

Describe("with a running hoverfly", func() {