mirror of
https://github.com/rclone/rclone.git
synced 2025-01-31 02:32:52 +01:00
fs: fix confusing "didn't find section in config file" error
This change decorates the error with the section name not found which will hopefully save user confusion. Fixes #8170
This commit is contained in:
parent
2c72842c10
commit
5316acd046
@ -2,6 +2,7 @@ package googlephotos
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -35,7 +36,7 @@ func TestIntegration(t *testing.T) {
|
|||||||
*fstest.RemoteName = "TestGooglePhotos:"
|
*fstest.RemoteName = "TestGooglePhotos:"
|
||||||
}
|
}
|
||||||
f, err := fs.NewFs(ctx, *fstest.RemoteName)
|
f, err := fs.NewFs(ctx, *fstest.RemoteName)
|
||||||
if err == fs.ErrorNotFoundInConfigFile {
|
if errors.Is(err, fs.ErrorNotFoundInConfigFile) {
|
||||||
t.Skipf("Couldn't create google photos backend - skipping tests: %v", err)
|
t.Skipf("Couldn't create google photos backend - skipping tests: %v", err)
|
||||||
}
|
}
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
4
fs/cache/cache_test.go
vendored
4
fs/cache/cache_test.go
vendored
@ -131,7 +131,7 @@ func TestPutErr(t *testing.T) {
|
|||||||
assert.Equal(t, 1, Entries())
|
assert.Equal(t, 1, Entries())
|
||||||
|
|
||||||
fNew, err := GetFn(context.Background(), "mock:/", create)
|
fNew, err := GetFn(context.Background(), "mock:/", create)
|
||||||
require.Equal(t, fs.ErrorNotFoundInConfigFile, err)
|
require.True(t, errors.Is(err, fs.ErrorNotFoundInConfigFile))
|
||||||
require.Equal(t, f, fNew)
|
require.Equal(t, f, fNew)
|
||||||
|
|
||||||
assert.Equal(t, 1, Entries())
|
assert.Equal(t, 1, Entries())
|
||||||
@ -141,7 +141,7 @@ func TestPutErr(t *testing.T) {
|
|||||||
PutErr("mock:/file.txt", f, fs.ErrorNotFoundInConfigFile)
|
PutErr("mock:/file.txt", f, fs.ErrorNotFoundInConfigFile)
|
||||||
|
|
||||||
fNew, err = GetFn(context.Background(), "mock:/file.txt", create)
|
fNew, err = GetFn(context.Background(), "mock:/file.txt", create)
|
||||||
require.Equal(t, fs.ErrorNotFoundInConfigFile, err)
|
require.True(t, errors.Is(err, fs.ErrorNotFoundInConfigFile))
|
||||||
require.Equal(t, f, fNew)
|
require.Equal(t, f, fNew)
|
||||||
|
|
||||||
assert.Equal(t, 1, Entries())
|
assert.Equal(t, 1, Entries())
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -104,7 +105,7 @@ func ParseRemote(path string) (fsInfo *RegInfo, configName, fsPath string, conne
|
|||||||
m := ConfigMap("", nil, configName, parsed.Config)
|
m := ConfigMap("", nil, configName, parsed.Config)
|
||||||
fsName, ok = m.Get("type")
|
fsName, ok = m.Get("type")
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, "", "", nil, ErrorNotFoundInConfigFile
|
return nil, "", "", nil, fmt.Errorf("%w (%q)", ErrorNotFoundInConfigFile, configName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -358,7 +358,7 @@ func TestRemoteServing(t *testing.T) {
|
|||||||
URL: "[notfoundremote:]/",
|
URL: "[notfoundremote:]/",
|
||||||
Status: http.StatusInternalServerError,
|
Status: http.StatusInternalServerError,
|
||||||
Expected: `{
|
Expected: `{
|
||||||
"error": "failed to make Fs: didn't find section in config file",
|
"error": "failed to make Fs: didn't find section in config file (\"notfoundremote\")",
|
||||||
"input": null,
|
"input": null,
|
||||||
"path": "/",
|
"path": "/",
|
||||||
"status": 500
|
"status": 500
|
||||||
|
@ -459,7 +459,7 @@ func Run(t *testing.T, opt *Opt) {
|
|||||||
subRemoteName, subRemoteLeaf, err = fstest.RandomRemoteName(remoteName)
|
subRemoteName, subRemoteLeaf, err = fstest.RandomRemoteName(remoteName)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
f, err = fs.NewFs(context.Background(), subRemoteName)
|
f, err = fs.NewFs(context.Background(), subRemoteName)
|
||||||
if err == fs.ErrorNotFoundInConfigFile {
|
if errors.Is(err, fs.ErrorNotFoundInConfigFile) {
|
||||||
t.Logf("Didn't find %q in config file - skipping tests", remoteName)
|
t.Logf("Didn't find %q in config file - skipping tests", remoteName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user