mirror of
https://github.com/rclone/rclone
synced 2024-09-06 00:08:57 +02:00
core/command: pretend to be "rclone version" to make tests pass
This commit is contained in:
parent
54fc2821cd
commit
4884bee8ba
@ -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"])
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user