Skip to content

Commit dfcbca9

Browse files
committed
webdav: if TestReadProppatch fails, print InnerXML as a string.
A string is more readable than the default representation of a []byte. Change-Id: I107c25aa09798df7c7766847beef4de124f44006 Reviewed-on: https://go-review.googlesource.com/10851 Reviewed-by: David Symonds <dsymonds@golang.org> Reviewed-by: Robert Stepanek <robert.stepanek@gmail.com>
1 parent dfe268f commit dfcbca9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

webdav/xml_test.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package webdav
77
import (
88
"bytes"
99
"encoding/xml"
10+
"fmt"
1011
"io"
1112
"net/http"
1213
"net/http/httptest"
@@ -634,6 +635,20 @@ loop:
634635
}
635636

636637
func TestReadProppatch(t *testing.T) {
638+
ppStr := func(pps []Proppatch) string {
639+
var outer []string
640+
for _, pp := range pps {
641+
var inner []string
642+
for _, p := range pp.Props {
643+
inner = append(inner, fmt.Sprintf("{XMLName: %q, Lang: %q, InnerXML: %q}",
644+
p.XMLName, p.Lang, p.InnerXML))
645+
}
646+
outer = append(outer, fmt.Sprintf("{Remove: %t, Props: [%s]}",
647+
pp.Remove, strings.Join(inner, ", ")))
648+
}
649+
return "[" + strings.Join(outer, ", ") + "]"
650+
}
651+
637652
// TODO(rost): These "golden XML" tests easily break with changes in the
638653
// xml package. A whitespace-preserving normalizer of XML content is
639654
// required to make these tests more robust.
@@ -806,7 +821,7 @@ func TestReadProppatch(t *testing.T) {
806821
continue
807822
}
808823
if !reflect.DeepEqual(pp, tc.wantPP) || status != tc.wantStatus {
809-
t.Errorf("%s: proppatch\ngot %v\nwant %v", tc.desc, pp, tc.wantPP)
824+
t.Errorf("%s: proppatch\ngot %v\nwant %v", tc.desc, ppStr(pp), ppStr(tc.wantPP))
810825
}
811826
}
812827
}

0 commit comments

Comments
 (0)