"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
Make http tests line ending agnostic
albertonyd8a874c32b8c
diff --git a/backend/http/http_internal_test.go b/backend/http/http_internal_test.goindex f2e791781..bd49503c5 100644--- a/backend/http/http_internal_test.go+++ b/backend/http/http_internal_test.go@@ -24,10 +24,11 @@ import ()var (- remoteName = "TestHTTP"- testPath = "test"- filesPath = filepath.Join(testPath, "files")- headers = []string{"X-Potato", "sausage", "X-Rhubarb", "cucumber"}+ remoteName = "TestHTTP"+ testPath = "test"+ filesPath = filepath.Join(testPath, "files")+ headers = []string{"X-Potato", "sausage", "X-Rhubarb", "cucumber"}+ lineEndSize = 1)// prepareServer the test server and return a function to tidy it up afterwards@@ -35,6 +36,22 @@ func prepareServer(t *testing.T) (configmap.Simple, func()) {// file server for test/filesfileServer := http.FileServer(http.Dir(filesPath))+ // verify the file path is correct, and also check which line endings+ // are used to get sizes right ("\n" except on Windows, but even there+ // we may have "\n" or "\r\n" depending on git crlf setting)+ fileList, err := ioutil.ReadDir(filesPath)+ require.NoError(t, err)+ require.Greater(t, len(fileList), 0)+ for _, file := range fileList {+ if !file.IsDir() {+ data, _ := ioutil.ReadFile(filepath.Join(filesPath, file.Name()))+ if strings.HasSuffix(string(data), "\r\n") {+ lineEndSize = 2+ }+ break+ }+ }+// test the headers are there then pass on to fileServerhandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {what := fmt.Sprintf("%s %s: Header ", r.Method, r.URL.Path)@@ -91,7 +108,7 @@ func testListRoot(t *testing.T, f fs.Fs, noSlash bool) {e = entries[1]assert.Equal(t, "one%.txt", e.Remote())- assert.Equal(t, int64(6), e.Size())+ assert.Equal(t, int64(5+lineEndSize), e.Size())_, ok = e.(*Object)assert.True(t, ok)@@ -108,7 +125,7 @@ func testListRoot(t *testing.T, f fs.Fs, noSlash bool) {_, ok = e.(fs.Directory)assert.True(t, ok)} else {- assert.Equal(t, int64(41), e.Size())+ assert.Equal(t, int64(40+lineEndSize), e.Size())_, ok = e.(*Object)assert.True(t, ok)}@@ -141,7 +158,7 @@ func TestListSubDir(t *testing.T) {e := entries[0]assert.Equal(t, "three/underthree.txt", e.Remote())- assert.Equal(t, int64(9), e.Size())+ assert.Equal(t, int64(8+lineEndSize), e.Size())_, ok := e.(*Object)assert.True(t, ok)}@@ -154,7 +171,7 @@ func TestNewObject(t *testing.T) {require.NoError(t, err)assert.Equal(t, "four/under four.txt", o.Remote())- assert.Equal(t, int64(9), o.Size())+ assert.Equal(t, int64(8+lineEndSize), o.Size())_, ok := o.(*Object)assert.True(t, ok)@@ -187,7 +204,11 @@ func TestOpen(t *testing.T) {data, err := ioutil.ReadAll(fd)require.NoError(t, err)require.NoError(t, fd.Close())- assert.Equal(t, "beetroot\n", string(data))+ if lineEndSize == 2 {+ assert.Equal(t, "beetroot\r\n", string(data))+ } else {+ assert.Equal(t, "beetroot\n", string(data))+ }// Test with range requestfd, err = o.Open(context.Background(), &fs.RangeOption{Start: 1, End: 5})@@ -236,7 +257,7 @@ func TestIsAFileSubDir(t *testing.T) {e := entries[0]assert.Equal(t, "underthree.txt", e.Remote())- assert.Equal(t, int64(9), e.Size())+ assert.Equal(t, int64(8+lineEndSize), e.Size())_, ok := e.(*Object)assert.True(t, ok)}