From 4884bee8bae206056cd913adfd9a78af7da1320b Mon Sep 17 00:00:00 2001
From: Nick Craig-Wood <nick@craig-wood.com>
Date: Mon, 27 Jul 2020 17:35:43 +0100
Subject: [PATCH] core/command: pretend to be "rclone version" to make tests
 pass

---
 fs/rc/internal_test.go | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

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"])
 }