Run runs the basic integration tests for a remote using the options passed in. They are structured in a hierarchical way so that dependencies for the tests can be created. For example some tests require the directory to be created - these are inside the "FsMkdir" test. Some tests require some tes
(t *testing.T, opt *Opt)
| 357 | // are inside the "FsMkdir" test. Some tests require some tests files |
| 358 | // - these are inside the "FsPutFiles" test. |
| 359 | func Run(t *testing.T, opt *Opt) { |
| 360 | var ( |
| 361 | f fs.Fs |
| 362 | remoteName = opt.RemoteName |
| 363 | subRemoteName string |
| 364 | subRemoteLeaf string |
| 365 | file1 = fstest.Item{ |
| 366 | ModTime: fstest.Time("2001-02-03T04:05:06.499999999Z"), |
| 367 | Path: "file name.txt", |
| 368 | } |
| 369 | file1Contents string |
| 370 | file1MimeType = "text/csv" |
| 371 | file1Metadata = fs.Metadata{"rclonetest": "potato"} |
| 372 | file2 = fstest.Item{ |
| 373 | ModTime: fstest.Time("2001-02-03T04:05:10.123123123Z"), |
| 374 | Path: `hello? sausage/êé/Hello, 世界/ " ' @ < > & ? + ≠/z.txt`, |
| 375 | } |
| 376 | isLocalRemote bool |
| 377 | purged bool // whether the dir has been purged or not |
| 378 | ctx = context.Background() |
| 379 | ci = fs.GetConfig(ctx) |
| 380 | unwrappableFsMethods = []string{"Command"} // these Fs methods don't need to be wrapped ever |
| 381 | ) |
| 382 | |
| 383 | if strings.HasSuffix(os.Getenv("RCLONE_CONFIG"), "/notfound") && *fstest.RemoteName == "" && !opt.QuickTestOK { |
| 384 | t.Skip("quicktest only") |
| 385 | } |
| 386 | |
| 387 | // Skip the test if the remote isn't configured |
| 388 | skipIfNotOk := func(t *testing.T) { |
| 389 | if f == nil { |
| 390 | t.Skipf("WARN: %q not configured", remoteName) |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | // Skip if remote is not ListR capable, otherwise set the useListR |
| 395 | // flag, returning a function to restore its value |
| 396 | skipIfNotListR := func(t *testing.T) func() { |
| 397 | skipIfNotOk(t) |
| 398 | if f.Features().ListR == nil { |
| 399 | t.Skip("FS has no ListR interface") |
| 400 | } |
| 401 | previous := ci.UseListR |
| 402 | ci.UseListR = true |
| 403 | return func() { |
| 404 | ci.UseListR = previous |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | // Skip if remote is not SetTier and GetTier capable |
| 409 | skipIfNotSetTier := func(t *testing.T) { |
| 410 | skipIfNotOk(t) |
| 411 | if !f.Features().SetTier || !f.Features().GetTier { |
| 412 | t.Skip("FS has no SetTier & GetTier interfaces") |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | // Return true if f (or any of the things it wraps) is bucket |