mirror of
https://github.com/rclone/rclone.git
synced 2025-01-18 04:09:41 +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 (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@ -35,7 +36,7 @@ func TestIntegration(t *testing.T) {
|
||||
*fstest.RemoteName = "TestGooglePhotos:"
|
||||
}
|
||||
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)
|
||||
}
|
||||
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())
|
||||
|
||||
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)
|
||||
|
||||
assert.Equal(t, 1, Entries())
|
||||
@ -141,7 +141,7 @@ func TestPutErr(t *testing.T) {
|
||||
PutErr("mock:/file.txt", f, fs.ErrorNotFoundInConfigFile)
|
||||
|
||||
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)
|
||||
|
||||
assert.Equal(t, 1, Entries())
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -104,7 +105,7 @@ func ParseRemote(path string) (fsInfo *RegInfo, configName, fsPath string, conne
|
||||
m := ConfigMap("", nil, configName, parsed.Config)
|
||||
fsName, ok = m.Get("type")
|
||||
if !ok {
|
||||
return nil, "", "", nil, ErrorNotFoundInConfigFile
|
||||
return nil, "", "", nil, fmt.Errorf("%w (%q)", ErrorNotFoundInConfigFile, configName)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -358,7 +358,7 @@ func TestRemoteServing(t *testing.T) {
|
||||
URL: "[notfoundremote:]/",
|
||||
Status: http.StatusInternalServerError,
|
||||
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,
|
||||
"path": "/",
|
||||
"status": 500
|
||||
|
@ -459,7 +459,7 @@ func Run(t *testing.T, opt *Opt) {
|
||||
subRemoteName, subRemoteLeaf, err = fstest.RandomRemoteName(remoteName)
|
||||
require.NoError(t, err)
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user