forked from TrueCloudLab/rclone
core/command: pretend to be "rclone version" to make tests pass
This commit is contained in:
parent
54fc2821cd
commit
4884bee8ba
1 changed files with 13 additions and 4 deletions
|
@ -2,6 +2,8 @@ package rc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -13,6 +15,15 @@ import (
|
||||||
"github.com/rclone/rclone/fs/version"
|
"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) {
|
func TestInternalNoop(t *testing.T) {
|
||||||
call := Calls.Get("rc/noop")
|
call := Calls.Get("rc/noop")
|
||||||
assert.NotNil(t, call)
|
assert.NotNil(t, call)
|
||||||
|
@ -132,8 +143,6 @@ func TestCoreCommand(t *testing.T) {
|
||||||
got, err := call.Fn(context.Background(), in)
|
got, err := call.Fn(context.Background(), in)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
errorBool, err := got.GetBool("error")
|
assert.Equal(t, fmt.Sprintf("rclone %s\n", fs.Version), got["result"])
|
||||||
require.NoError(t, err)
|
assert.Equal(t, false, got["error"])
|
||||||
|
|
||||||
require.Equal(t, errorBool, false)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue