@@ -780,3 +780,70 @@ func TestImportImportRequestResponsePairs_ReturnsWarningsContentLengthMismatch(t
780780 Expect (result .WarningMessages ).To (HaveLen (1 ))
781781 Expect (result .WarningMessages [0 ].Message ).To (ContainSubstring ("Response contains incorrect Content-Length header on data.pairs[0].response, please correct or remove header" ))
782782}
783+
784+ func TestImportImportRequestResponsePairs_ReturnsNoWarnings (t * testing.T ) {
785+ RegisterTestingT (t )
786+
787+ cache := cache .NewInMemoryCache ()
788+ cfg := Configuration {Webserver : false }
789+ cacheMatcher := matching.CacheMatcher {RequestCache : cache , Webserver : cfg .Webserver }
790+ hv := Hoverfly {Cfg : & cfg , CacheMatcher : cacheMatcher , Simulation : models .NewSimulation ()}
791+
792+ RegisterTestingT (t )
793+
794+ encodedPair := v2.RequestMatcherResponsePairViewV5 {
795+ Response : v2.ResponseDetailsViewV5 {
796+ Status : 200 ,
797+ Body : "hello_world" ,
798+ Headers : map [string ][]string {
799+ "Content-Length" : []string {"11" },
800+ },
801+ },
802+ RequestMatcher : v2.RequestMatcherViewV5 {
803+ Destination : []v2.MatcherViewV5 {
804+ v2.MatcherViewV5 {
805+ Matcher : "exact" ,
806+ Value : "hoverfly.io" ,
807+ },
808+ },
809+ },
810+ }
811+
812+ result := hv .importRequestResponsePairViews ([]v2.RequestMatcherResponsePairViewV5 {encodedPair })
813+
814+ Expect (result .WarningMessages ).To (HaveLen (0 ))
815+ }
816+
817+ func TestImportImportRequestResponsePairs_ReturnsNoWarnings_Encoded (t * testing.T ) {
818+ RegisterTestingT (t )
819+
820+ cache := cache .NewInMemoryCache ()
821+ cfg := Configuration {Webserver : false }
822+ cacheMatcher := matching.CacheMatcher {RequestCache : cache , Webserver : cfg .Webserver }
823+ hv := Hoverfly {Cfg : & cfg , CacheMatcher : cacheMatcher , Simulation : models .NewSimulation ()}
824+
825+ RegisterTestingT (t )
826+
827+ encodedPair := v2.RequestMatcherResponsePairViewV5 {
828+ Response : v2.ResponseDetailsViewV5 {
829+ Status : 200 ,
830+ Body : base64String ("hello_world" ),
831+ EncodedBody : true ,
832+ Headers : map [string ][]string {
833+ "Content-Length" : []string {"11" },
834+ },
835+ },
836+ RequestMatcher : v2.RequestMatcherViewV5 {
837+ Destination : []v2.MatcherViewV5 {
838+ v2.MatcherViewV5 {
839+ Matcher : "exact" ,
840+ Value : "hoverfly.io" ,
841+ },
842+ },
843+ },
844+ }
845+
846+ result := hv .importRequestResponsePairViews ([]v2.RequestMatcherResponsePairViewV5 {encodedPair })
847+
848+ Expect (result .WarningMessages ).To (HaveLen (0 ))
849+ }
0 commit comments