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

core/command: pretend to be "rclone version" to make tests pass

Nick Craig-Wood4884bee8bae2
diff --git a/fs/rc/internal_test.go b/fs/rc/internal_test.go
index c22bf3a57..0515c63bc 100644
--- a/fs/rc/internal_test.go
+++ b/fs/rc/internal_test.go
@@ -2,6 +2,8 @@ package rc
import (
"context"
+ "fmt"
+ "os"
"runtime"
"testing"
@@ -13,6 +15,15 @@ import (
"github.com/rclone/rclone/fs/version"
)
+func TestMain(m *testing.M) {
+ // Pretend to be rclone version if we have a version string parameter
+ if os.Args[len(os.Args)-1] == "version" {
+ fmt.Printf("rclone %s\n", fs.Version)
+ os.Exit(0)
+ }
+ os.Exit(m.Run())
+}
+
func TestInternalNoop(t *testing.T) {
call := Calls.Get("rc/noop")
assert.NotNil(t, call)
@@ -132,8 +143,6 @@ func TestCoreCommand(t *testing.T) {
got, err := call.Fn(context.Background(), in)
require.NoError(t, err)
- errorBool, err := got.GetBool("error")
- require.NoError(t, err)
-
- require.Equal(t, errorBool, false)
+ assert.Equal(t, fmt.Sprintf("rclone %s\n", fs.Version), got["result"])
+ assert.Equal(t, false, got["error"])
}