From ce2035ed6e751dbed23b65db3b6d7b79342a792d Mon Sep 17 00:00:00 2001 From: Tommy Situ Date: Thu, 11 Jul 2024 22:33:50 +0100 Subject: [PATCH] Upgrade simulation schema version to v5.3 --- core/handlers/v2/simulation_views.go | 2 +- core/handlers/v2/simulation_views_test.go | 6 +++--- core/handlers/v2/simulation_views_upgrade.go | 2 +- core/handlers/v2/simulation_views_upgrade_test.go | 6 +++--- core/hoverfly_service_test.go | 4 ++-- functional-tests/core/api/simulation_api_v2_test.go | 4 ++-- functional-tests/hoverctl/import_export_test.go | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/core/handlers/v2/simulation_views.go b/core/handlers/v2/simulation_views.go index ae682d9dd..65976e8dd 100644 --- a/core/handlers/v2/simulation_views.go +++ b/core/handlers/v2/simulation_views.go @@ -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), } } diff --git a/core/handlers/v2/simulation_views_test.go b/core/handlers/v2/simulation_views_test.go index 02408728f..dd7f90eae 100644 --- a/core/handlers/v2/simulation_views_test.go +++ b/core/handlers/v2/simulation_views_test.go @@ -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")) } diff --git a/core/handlers/v2/simulation_views_upgrade.go b/core/handlers/v2/simulation_views_upgrade.go index f85f13bdb..5765909b3 100644 --- a/core/handlers/v2/simulation_views_upgrade.go +++ b/core/handlers/v2/simulation_views_upgrade.go @@ -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, } diff --git a/core/handlers/v2/simulation_views_upgrade_test.go b/core/handlers/v2/simulation_views_upgrade_test.go index 1fd5b7652..134d4cda0 100644 --- a/core/handlers/v2/simulation_views_upgrade_test.go +++ b/core/handlers/v2/simulation_views_upgrade_test.go @@ -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")) } diff --git a/core/hoverfly_service_test.go b/core/hoverfly_service_test.go index 7e8765e3f..e17fd9310 100644 --- a/core/hoverfly_service_test.go +++ b/core/hoverfly_service_test.go @@ -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()) } diff --git a/functional-tests/core/api/simulation_api_v2_test.go b/functional-tests/core/api/simulation_api_v2_test.go index 1737bdfbc..f140694b8 100644 --- a/functional-tests/core/api/simulation_api_v2_test.go +++ b/functional-tests/core/api/simulation_api_v2_test.go @@ -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()) diff --git a/functional-tests/hoverctl/import_export_test.go b/functional-tests/hoverctl/import_export_test.go index f63fb4ce5..82e989421 100644 --- a/functional-tests/hoverctl/import_export_test.go +++ b/functional-tests/hoverctl/import_export_test.go @@ -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() {