Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

webdav: fix tests after go1.20 upgrade

Nick Craig-Wood2d1c2725e451
diff --git a/backend/webdav/webdav_internal_test.go b/backend/webdav/webdav_internal_test.go
index 8789e8413..20dee468b 100644
--- a/backend/webdav/webdav_internal_test.go
+++ b/backend/webdav/webdav_internal_test.go
@@ -24,15 +24,23 @@ var (
// prepareServer the test server and return a function to tidy it up afterwards
// with each request the headers option tests are executed
func prepareServer(t *testing.T) (configmap.Simple, func()) {
- // file server
- fileServer := http.FileServer(http.Dir(""))
-
- // test the headers are there then pass on to fileServer
+ // test the headers are there send send a dummy response to About
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
what := fmt.Sprintf("%s %s: Header ", r.Method, r.URL.Path)
assert.Equal(t, headers[1], r.Header.Get(headers[0]), what+headers[0])
assert.Equal(t, headers[3], r.Header.Get(headers[2]), what+headers[2])
- fileServer.ServeHTTP(w, r)
+ fmt.Fprintf(w, `<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
+<d:response>
+ <d:href>/remote.php/webdav/</d:href>
+ <d:propstat>
+ <d:prop>
+ <d:quota-available-bytes>-3</d:quota-available-bytes>
+ <d:quota-used-bytes>376461895</d:quota-used-bytes>
+ </d:prop>
+ <d:status>HTTP/1.1 200 OK</d:status>
+ </d:propstat>
+</d:response>
+</d:multistatus>`)
})
// Make the test server
@@ -68,7 +76,7 @@ func TestHeaders(t *testing.T) {
f, tidy := prepare(t)
defer tidy()
- // any request will do
+ // send an About response since that is all the dummy server can return
_, err := f.Features().About(context.Background())
require.NoError(t, err)
}