This commit is contained in:
hong-revo 2019-02-06 17:01:52 +11:00
Родитель b8885acc99
Коммит 0c026b16c3
1 изменённых файлов: 32 добавлений и 33 удалений

Просмотреть файл

@ -151,45 +151,44 @@ test_that("ADLSgen2 client interface works",
})
# test_that("AAD authentication works",
# {
# url <- stor$get_adls_endpoint()$url
# token <- AzureRMR::get_azure_token(url, tenant=tenant, app=app, password=password)
# ad <- adls_endpoint(url, token=token)
# fs <- create_adls_filesystem(ad, "newfs4")
test_that("AAD authentication works",
{
url <- stor$get_adls_endpoint()$url
token <- AzureRMR::get_azure_token("https://storage.azure.com/", tenant=tenant, app=app, password=password)
ad <- adls_endpoint(url, token=token)
fs <- create_adls_filesystem(ad, "newfs4")
# # upload and download
# orig_file <- "../resources/iris.csv"
# upload_adls_file(fs, orig_file, "iris.csv")
# tok_dl <- file.path(tempdir(), "iris_tok.csv")
# suppressWarnings(file.remove(tok_dl))
# download_adls_file(fs, "iris.csv", tok_dl)
# expect_identical(readBin(orig_file, "raw", n=1e5), readBin(tok_dl, "raw", n=1e5))
# upload and download
orig_file <- "../resources/iris.csv"
upload_adls_file(fs, orig_file, "iris.csv")
tok_dl <- file.path(tempdir(), "iris_tok.csv")
suppressWarnings(file.remove(tok_dl))
download_adls_file(fs, "iris.csv", tok_dl)
expect_identical(readBin(orig_file, "raw", n=1e5), readBin(tok_dl, "raw", n=1e5))
# # multiple upload and download
# files <- lapply(1:10, function(f) paste0(sample(letters, 1000, replace=TRUE), collapse=""))
# filenames <- sapply(1:10, function(n) file.path(tempdir(), sprintf("multitransfer_%d", n)))
# suppressWarnings(file.remove(filenames))
# mapply(writeLines, files, filenames)
# multiple upload and download
files <- lapply(1:10, function(f) paste0(sample(letters, 1000, replace=TRUE), collapse=""))
filenames <- sapply(1:10, function(n) file.path(tempdir(), sprintf("multitransfer_%d", n)))
suppressWarnings(file.remove(filenames))
mapply(writeLines, files, filenames)
# multiupload_adls_file(fs, file.path(tempdir(), "multitransfer_*"))
# expect_warning(multiupload_adls_file(fs, file.path(tempdir(), "multitransfer_*"), "newnames"))
multiupload_adls_file(fs, file.path(tempdir(), "multitransfer_*"), "/")
# dest_dir <- file.path(tempdir(), "adls_multitransfer")
# suppressWarnings(unlink(dest_dir, recursive=TRUE))
# dir.create(dest_dir)
# multidownload_adls_file(fs, "multitransfer_*", dest_dir, overwrite=TRUE)
dest_dir <- file.path(tempdir(), "adls_multitransfer")
suppressWarnings(unlink(dest_dir, recursive=TRUE))
dir.create(dest_dir)
multidownload_adls_file(fs, "multitransfer_*", dest_dir, overwrite=TRUE)
# expect_true(all(sapply(filenames, function(f)
# {
# src <- readBin(f, "raw", n=1e5)
# dest <- readBin(file.path(dest_dir, basename(f)), "raw", n=1e5)
# identical(src, dest)
# })))
expect_true(all(sapply(filenames, function(f)
{
src <- readBin(f, "raw", n=1e5)
dest <- readBin(file.path(dest_dir, basename(f)), "raw", n=1e5)
identical(src, dest)
})))
# delete_adls_filesystem(fs, confirm=FALSE)
# expect_true(is_empty(list_adls_filesystems(ad)))
# })
delete_adls_filesystem(fs, confirm=FALSE)
expect_true(is_empty(list_adls_filesystems(ad)))
})
teardown(