testing: add -remote flag to allow unit tests to run on other remotes

Use this on the individual fs unit tests, eg

    cd s3
    go run -v -remote mytestS3:
This commit is contained in:
Nick Craig-Wood 2015-08-15 15:40:18 +01:00
parent e320f4a988
commit 40b3c4883f
1 changed files with 6 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
"bytes" "bytes"
"crypto/md5" "crypto/md5"
"encoding/hex" "encoding/hex"
"flag"
"io" "io"
"log" "log"
"os" "os"
@ -32,11 +33,16 @@ var (
} }
) )
func init() {
flag.StringVar(&RemoteName, "remote", "", "Set this to override the default remote name (eg s3:)")
}
func TestInit(t *testing.T) { func TestInit(t *testing.T) {
var err error var err error
fs.LoadConfig() fs.LoadConfig()
fs.Config.Verbose = false fs.Config.Verbose = false
fs.Config.Quiet = true fs.Config.Quiet = true
t.Logf("Using remote %q", RemoteName)
if RemoteName == "" { if RemoteName == "" {
RemoteName, err = fstest.LocalRemote() RemoteName, err = fstest.LocalRemote()
if err != nil { if err != nil {