Documentation ¶
Overview ¶
Package fstest provides utilities for testing the Fs
Index ¶
- Variables
- func CheckItems(t *testing.T, f fs.Fs, items ...Item)
- func CheckListing(t *testing.T, f fs.Fs, items []Item)
- func CheckListingWithPrecision(t *testing.T, f fs.Fs, items []Item, expectedDirs []string, ...)
- func CheckTimeEqualWithPrecision(t0, t1 time.Time, precision time.Duration) (time.Duration, bool)
- func Initialise()
- func LocalRemote() (path string, err error)
- func Normalize(name string) string
- func RandomRemote(remoteName string, subdir bool) (fs.Fs, string, func(), error)
- func RandomRemoteName(remoteName string) (string, string, error)
- func RandomString(n int) string
- func TestMain(m *testing.M)
- func TestMkdir(t *testing.T, remote fs.Fs)
- func TestPurge(t *testing.T, remote fs.Fs)
- func TestRmdir(t *testing.T, remote fs.Fs)
- func Time(timeString string) time.Time
- type Item
- type Items
- type Run
- func (r *Run) CheckWithDuplicates(t *testing.T, items ...Item)
- func (r *Run) Finalise()
- func (r *Run) ForceMkdir(f fs.Fs)
- func (r *Run) Mkdir(f fs.Fs)
- func (r *Run) RenameFile(item Item, newpath string) Item
- func (r *Run) WriteBoth(remote, content string, modTime time.Time) Item
- func (r *Run) WriteFile(filePath, content string, t time.Time) Item
- func (r *Run) WriteObject(remote, content string, modTime time.Time) Item
- func (r *Run) WriteObjectTo(f fs.Fs, remote, content string, modTime time.Time, useUnchecked bool) Item
- func (r *Run) WriteUncheckedObject(remote, content string, modTime time.Time) Item
Constants ¶
This section is empty.
Variables ¶
var ( RemoteName = flag.String("remote", "", "Remote to test with, defaults to local filesystem") SubDir = flag.Bool("subdir", false, "Set to test with a sub directory") Verbose = flag.Bool("verbose", false, "Set to enable logging") DumpHeaders = flag.Bool("dump-headers", false, "Set to dump headers (needs -verbose)") DumpBodies = flag.Bool("dump-bodies", false, "Set to dump bodies (needs -verbose)") Individual = flag.Bool("individual", false, "Make individual bucket/container/directory for each test - much slower") LowLevelRetries = flag.Int("low-level-retries", 10, "Number of low level retries") UseListR = flag.Bool("fast-list", false, "Use recursive list if available. Uses more memory but fewer transactions.") // ListRetries is the number of times to retry a listing to overcome eventual consistency ListRetries = flag.Int("list-retries", 6, "Number or times to retry listing") // MatchTestRemote matches the remote names used for testing MatchTestRemote = regexp.MustCompile(`^rclone-test-[abcdefghijklmnopqrstuvwxyz0123456789]{24}$`) )
Globals
Functions ¶
func CheckItems ¶
CheckItems checks the fs to see if it has only the items passed in using a precision of fs.Config.ModifyWindow
func CheckListing ¶
CheckListing checks the fs to see if it has the expected contents
func CheckListingWithPrecision ¶
func CheckListingWithPrecision(t *testing.T, f fs.Fs, items []Item, expectedDirs []string, precision time.Duration)
CheckListingWithPrecision checks the fs to see if it has the expected contents with the given precision.
If expectedDirs is non nil then we check those too. Note that no directories returned is also OK as some remotes don't return directories.
func CheckTimeEqualWithPrecision ¶
CheckTimeEqualWithPrecision checks the times are equal within the precision, returns the delta and a flag
func LocalRemote ¶
LocalRemote creates a temporary directory name for local remotes
func Normalize ¶
Normalize runs a utf8 normalization on the string if running on OS X. This is because OS X denormalizes file names it writes to the local file system.
func RandomRemote ¶
RandomRemote makes a random bucket or subdirectory on the remote
Call the finalise function returned to Purge the fs at the end (and the parent if necessary)
Returns the remote, its url, a finaliser and an error
func RandomRemoteName ¶
RandomRemoteName makes a random bucket or subdirectory name
Returns a random remote name plus the leaf name
func RandomString ¶
RandomString create a random string for test purposes
Types ¶
type Item ¶
type Item struct { Path string Hashes map[fs.HashType]string ModTime time.Time Size int64 WinPath string }
Item represents an item for checking
func (*Item) CheckHashes ¶
CheckHashes checks all the hashes the object supports are correct
type Items ¶
type Items struct {
// contains filtered or unexported fields
}
Items represents all items for checking
type Run ¶
type Run struct { LocalName string Flocal fs.Fs Fremote fs.Fs FremoteName string Logf, Fatalf func(text string, args ...interface{}) // contains filtered or unexported fields }
Run holds the remotes for a test run
func NewRun ¶
NewRun initialise the remote and local for testing and returns a run object. Call this from the tests.
r.Flocal is an empty local Fs r.Fremote is an empty remote Fs
Finalise() will tidy them away when done.
func (*Run) CheckWithDuplicates ¶
CheckWithDuplicates does a test but allows duplicates
func (*Run) RenameFile ¶
RenameFile renames a file in local
func (*Run) WriteObject ¶
WriteObject writes an object to the remote