Browse Source

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>
Nigel Tao 10 years ago
parent
commit
dfcbca9c45
1 changed files with 16 additions and 1 deletions
  1. 16 1
      webdav/xml_test.go

+ 16 - 1
webdav/xml_test.go

@@ -7,6 +7,7 @@ package webdav
 import (
 	"bytes"
 	"encoding/xml"
+	"fmt"
 	"io"
 	"net/http"
 	"net/http/httptest"
@@ -634,6 +635,20 @@ loop:
 }
 
 func TestReadProppatch(t *testing.T) {
+	ppStr := func(pps []Proppatch) string {
+		var outer []string
+		for _, pp := range pps {
+			var inner []string
+			for _, p := range pp.Props {
+				inner = append(inner, fmt.Sprintf("{XMLName: %q, Lang: %q, InnerXML: %q}",
+					p.XMLName, p.Lang, p.InnerXML))
+			}
+			outer = append(outer, fmt.Sprintf("{Remove: %t, Props: [%s]}",
+				pp.Remove, strings.Join(inner, ", ")))
+		}
+		return "[" + strings.Join(outer, ", ") + "]"
+	}
+
 	// TODO(rost): These "golden XML" tests easily break with changes in the
 	// xml package. A whitespace-preserving normalizer of XML content is
 	// required to make these tests more robust.
@@ -806,7 +821,7 @@ func TestReadProppatch(t *testing.T) {
 			continue
 		}
 		if !reflect.DeepEqual(pp, tc.wantPP) || status != tc.wantStatus {
-			t.Errorf("%s: proppatch\ngot  %v\nwant %v", tc.desc, pp, tc.wantPP)
+			t.Errorf("%s: proppatch\ngot  %v\nwant %v", tc.desc, ppStr(pp), ppStr(tc.wantPP))
 		}
 	}
 }