This script aggregates the test-related clean code from all test files.

library(googledrive)
source(rprojroot::find_testthat_root_file('helper.R'))
## in token_fetch()
## trying credentials_service account
## email: gargle-service-account@gargle-169921.iam.gserviceaccount.com
## Test file naming scheme:
##   * foo-TEST-context-jenny
whoami <- drive_user()$user
whoami[c('displayName', 'emailAddress')]
## NULL
## change this to TRUE when you are really ready to do this!
CLEAN <- TRUE

test-drive_cp.R

me_ <- nm_fun("TEST-drive-cp")
nm_ <- nm_fun("TEST-drive-cp", NULL)
if (CLEAN) {
  drive_trash(c(
    nm_("i-am-a-folder"),
    nm_("not-unique-folder"),
    nm_("i-am-a-file")
  ))
}
## Files trashed:
##   * i-am-a-folder-TEST-drive-cp: 13Ur3qR8iu3yEswUOMXPDzLoK6WdHtGGZ
##   * not-unique-folder-TEST-drive-cp: 1Uz4vku-qO3iYelVAmJlLCOcL_2_owij2
##   * not-unique-folder-TEST-drive-cp: 1_4vv2gdjYem20DIE8t2Qp-ZFZPVqsAFA
##   * i-am-a-file-TEST-drive-cp: 1TdEzIkiTk2XjwaqoRay-v_qAdFjVzWzo

test-drive_download.R

nm_ <- nm_fun("TEST-drive-download", NULL)
if (CLEAN) {
  drive_trash(c(
    nm_("DESC"),
    nm_("DESC-doc")
  ))
}
## Files trashed:
##   * DESC-TEST-drive-download: 1V4r-ay5nSagxMAKVO_3GmixRuz-6bFOb
##   * DESC-doc-TEST-drive-download: 1ldupR0ko1fU20LBqgHU1RZvsMB7Q0XmLln76q5wuKik

test-drive_find.R

me_ <- nm_fun("TEST-drive-find")
nm_ <- nm_fun("TEST-drive-find", NULL)
if (CLEAN) {
  drive_trash(c(
    nm_("find-me"),
    nm_("this-should-not-exist")
  ))
}
## Files trashed:
##   * find-me-TEST-drive-find: 1r_smPstXpskEZ1mnkqEebx04Wmvzcv7q

test-drive_get.R

nm_ <- nm_fun("TEST-drive-get", NULL)
if (CLEAN) {
  files <- drive_find(nm_("thing0[1234]"))
  drive_trash(files)
  parents <- drive_find(nm_("parent0[12]"))
  drive_trash(parents)
  drive_trash(nm_("child_of_2_parents"))
}
## Files trashed:
##   * thing04-TEST-drive-get: 15Ca6Cx9aAT0zvNLmrorlu92RridHrXua
##   * thing01-TEST-drive-get: 166bpasfMwOMbKEeE8yYau2CvkSdBcqND
##   * thing01-TEST-drive-get: 1vuAwVlhOXGNOd5iOLhaeQDzkOLr_7qkP
##   * thing01-TEST-drive-get: 1Vjf6AHL3YAs6vG2gIcxI2k-CgKQsYnci
##   * thing03-TEST-drive-get: 1pLXPsf5sKr52rulO51j85Ycw6r7jIG_5
##   * thing02-TEST-drive-get: 1Kmzt_WXahnESip0BVHCvzq4zlpyYwbgP
##   * thing01-TEST-drive-get: 1WcrtxZj3dib3e8lJhMOz-447DuGEpb4U
##   * thing04-TEST-drive-get: 1pOgTHJjl4_LVJgirr9Ny_yQ2A9cVFTwk
##   * thing01-TEST-drive-get: 1N_xHh_oB9fV8urvsG_I0K4N9FQdOW4hT
##   * thing01-TEST-drive-get: 1hET84fab2aRjZcjH-sXF0oEC6t6xezpX
##   * thing01-TEST-drive-get: 1v36ENtsfrgj2miZbjhAyznxPzHiiCX9x
##   * thing03-TEST-drive-get: 1Od3LMlDap1rwcU_FFQE-jtEZ9sIxtKwB
##   * thing02-TEST-drive-get: 1QFLH0x0NRLpysYSqc6JvJG53cFLuj8Og
##   * thing01-TEST-drive-get: 1qvGWhR6WzCRQeggd9aIpLAr3ZrE4I6xH
## Files trashed:
##   * parent02-TEST-drive-get: 1tn5xJglxALAW-jMi9JDrN3FWInnYVlRh
##   * parent01-TEST-drive-get: 19gptWkJ2iZOFVnx9BbDJFoBzeFpYbmnO
##   * parent02-TEST-drive-get: 1FbEXaO_Ek4EWTkEOjVBk1rs5Ey5xygi0
##   * parent01-TEST-drive-get: 1nVPuZX96q0S3NgU6-vMwRMXgNOaE9JjA
## Files trashed:
##   * child_of_2_parents-TEST-drive-get: 1lgYOC_GeFbkj4gq7jP47Cea8tYHE3yoq

test-drive_ls.R

nm_ <- nm_fun("TEST-drive-ls", NULL)
if (CLEAN) {
  drive_trash(c(
    nm_("list-me"),
    nm_("this-should-not-exist")
  ))
}
## No such files found to trash.

test-drive_mkdir.R

me_ <- nm_fun("TEST-drive-mkdir")
nm_ <- nm_fun("TEST-drive-mkdir", NULL)
if (CLEAN) {
  drive_trash(c(
    nm_("OMNI-PARENT"),
    nm_("I-live-in-root")
  ))
}
## No such files found to trash.

test-drive_mv.R

me_ <- nm_fun("TEST-drive-mv")
nm_ <- nm_fun("TEST-drive-mv", NULL)
if (CLEAN) {
  drive_trash(c(
    nm_("move-files-into-me"),
    nm_("DESC"),
    nm_("DESC-renamed")
  ))
}
## No such files found to trash.

test-drive_publish.R

nm_ <- nm_fun("TEST-drive-publish", NULL)
if (CLEAN) {
  drive_trash(c(
    nm_("foo_pdf"),
    nm_("foo_doc"),
    nm_("foo_sheet")
  ))
}
## No such files found to trash.

test-drive_share.R

me_ <- nm_fun("TEST-drive-share")
nm_ <- nm_fun("TEST-drive-share", NULL)
if (CLEAN) {
  drive_trash(c(
    nm_("mirrors-to-share"),
    nm_("DESC")
  ))
}
## No such files found to trash.

test-drive_trash.R

me_ <- nm_fun("TEST-drive-trash")
nm_ <- nm_fun("TEST-drive-trash", NULL)
if (CLEAN) {
  drive_trash(c(
    nm_("trash-fodder"),
    me_("trashee-1"),
    me_("trashee-2")
  ))
}
## No such files found to trash.

test-drive_update.R

me_ <- nm_fun("TEST-drive-update")
nm_ <- nm_fun("TEST-drive-update", NULL)
if (CLEAN) {
  drive_trash(c(
    nm_("update-fodder"),
    nm_("not-unique"),
    nm_("does-not-exist")
  ))
}
## No such files found to trash.

test-drive_upload.R

me_ <- nm_fun("TEST-drive-upload")
nm_ <- nm_fun("TEST-drive-upload", NULL)
if (CLEAN) {
  drive_trash(c(
    nm_("upload-into-me"),
    nm_("DESCRIPTION")
  ))
}
## No such files found to trash.