1
0
mirror of https://github.com/rclone/rclone.git synced 2026-02-09 21:20:10 +00:00

rc: listremotes should send an empty array instead of nil

This commit is contained in:
n4n5
2025-07-25 16:37:25 +02:00
committed by GitHub
parent ff9cbab5fa
commit db4812fbfa
2 changed files with 19 additions and 0 deletions

View File

@@ -106,6 +106,9 @@ See the [listremotes](/commands/rclone_listremotes/) command for more informatio
// including any defined by environment variables.
func rcListRemotes(ctx context.Context, in rc.Params) (out rc.Params, err error) {
remoteNames := GetRemoteNames()
if remoteNames == nil {
remoteNames = []string{}
}
out = rc.Params{
"remotes": remoteNames,
}

View File

@@ -138,6 +138,22 @@ func TestRc(t *testing.T) {
assert.Nil(t, out)
assert.Equal(t, "", config.GetValue(testName, "type"))
assert.Equal(t, "", config.GetValue(testName, "test_key"))
t.Run("ListRemotes empty not nil", func(t *testing.T) {
call := rc.Calls.Get("config/listremotes")
assert.NotNil(t, call)
in := rc.Params{}
out, err := call.Fn(context.Background(), in)
require.NoError(t, err)
require.NotNil(t, out)
var remotes []string
err = out.GetStruct("remotes", &remotes)
require.NoError(t, err)
assert.NotNil(t, remotes)
assert.Empty(t, remotes)
})
}
func TestRcProviders(t *testing.T) {