File tree Expand file tree Collapse file tree
packages/hurl/src/report/junit Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -200,7 +200,7 @@ mod tests {
200200 let suite = create_testsuite ( & testcases, & secrets) ;
201201 let doc = XmlDocument :: new ( suite) ;
202202 assert_eq ! (
203- doc. to_string ( ) . unwrap ( ) ,
203+ doc. dump ( ) ,
204204 "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\
205205 <testsuite tests=\" 3\" errors=\" 1\" failures=\" 1\" >\
206206 <testcase id=\" test.hurl\" name=\" test.hurl\" time=\" 0.124\" />\
Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ mod test {
119119 let element = Testcase :: from ( & hurl_result, content, & filename) . to_xml ( & secrets) ;
120120 let doc = XmlDocument :: new ( element) ;
121121 assert_eq ! (
122- doc. to_string ( ) . unwrap ( ) ,
122+ doc. dump ( ) ,
123123 r#"<?xml version="1.0" encoding="UTF-8"?><testcase id="test.hurl" name="test.hurl" time="0.230" />"#
124124 ) ;
125125 }
@@ -152,7 +152,7 @@ HTTP/1.0 200
152152 let element = Testcase :: from ( & hurl_result, content, & filename) . to_xml ( & secrets) ;
153153 let doc = XmlDocument :: new ( element) ;
154154 assert_eq ! (
155- doc. to_string ( ) . unwrap ( ) ,
155+ doc. dump ( ) ,
156156 r#"<?xml version="1.0" encoding="UTF-8"?><testcase id="test.hurl" name="test.hurl" time="0.230"><failure>Assert status code
157157 --> test.hurl:2:10
158158 |
@@ -189,7 +189,7 @@ HTTP/1.0 200
189189 let element = Testcase :: from ( & hurl_result, content, & filename) . to_xml ( & secrets) ;
190190 let doc = XmlDocument :: new ( element) ;
191191 assert_eq ! (
192- doc. to_string ( ) . unwrap ( ) ,
192+ doc. dump ( ) ,
193193 r#"<?xml version="1.0" encoding="UTF-8"?><testcase id="test.hurl" name="test.hurl" time="0.230"><error>HTTP connection
194194 --> test.hurl:1:5
195195 |
Original file line number Diff line number Diff line change @@ -65,15 +65,6 @@ impl From<FromUtf8Error> for WriterError {
6565}
6666
6767impl XmlDocument {
68- /// Convenient method to serialize an XML document to a string.
69- #[ allow( dead_code) ]
70- pub fn to_string ( & self ) -> Result < String , WriterError > {
71- let buffer = vec ! [ ] ;
72- let buffer = self . write ( buffer) ?;
73- let str = String :: from_utf8 ( buffer) ?;
74- Ok ( str)
75- }
76-
7768 /// Serializes an XML document to a `buffer`.
7869 pub fn write < W > ( & self , buffer : W ) -> Result < W , WriterError >
7970 where
@@ -146,6 +137,15 @@ impl Element {
146137mod tests {
147138 use crate :: report:: junit:: xml:: { Element , XmlDocument } ;
148139
140+ impl XmlDocument {
141+ /// Convenient method to serialize an XML document to a string.
142+ pub fn dump ( & self ) -> String {
143+ let buffer = vec ! [ ] ;
144+ let buffer = self . write ( buffer) . unwrap ( ) ;
145+ String :: from_utf8 ( buffer) . unwrap ( )
146+ }
147+ }
148+
149149 #[ test]
150150 fn write_xml_0 ( ) {
151151 let root = Element :: new ( "catalog" )
@@ -208,7 +208,7 @@ mod tests {
208208 ;
209209 let doc = XmlDocument { root : Some ( root) } ;
210210 assert_eq ! (
211- doc. to_string ( ) . unwrap ( ) ,
211+ doc. dump ( ) ,
212212 "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\
213213 <catalog>\
214214 <book id=\" bk101\" >\
You can’t perform that action at this time.
0 commit comments