From 041f42f7cb57bfb7290caf6be8d527cd938c97ae Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Fri, 3 Jan 2020 09:58:36 -0500 Subject: [PATCH] dedicate a test file to a single function https://style.tidyverse.org/tests.html#organisation-1 ref #4 --- tests/testthat/tests-get_file.R | 21 +++++++++++++++++++ ...ata-access.R => tests-get_file_metadata.R} | 17 --------------- 2 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 tests/testthat/tests-get_file.R rename tests/testthat/{tests-data-access.R => tests-get_file_metadata.R} (58%) diff --git a/tests/testthat/tests-get_file.R b/tests/testthat/tests-get_file.R new file mode 100644 index 0000000..3ef5511 --- /dev/null +++ b/tests/testthat/tests-get_file.R @@ -0,0 +1,21 @@ +context("Data Access API") + +# See https://demo.dataverse.org/dataverse/dataverse-client-r +# https://doi.org/10.70122/FK2/FAN622 + +test_that("download file from DOI and filename", { + actual <- get_file( + file = "roster-bulls-1996.tab", + dataset = "doi:10.70122/FK2/FAN622" + ) + expect_true(is.raw(actual)) + expect_true(1000 < object.size(actual)) # Should be 1+ KB +}) + +test_that("download file from file id", { + actual <- get_file( + file = 396357 + ) + expect_true(is.raw(actual)) + expect_true(1000 < object.size(actual)) # Should be 1+ KB +}) diff --git a/tests/testthat/tests-data-access.R b/tests/testthat/tests-get_file_metadata.R similarity index 58% rename from tests/testthat/tests-data-access.R rename to tests/testthat/tests-get_file_metadata.R index e2a872a..2bb7ab6 100644 --- a/tests/testthat/tests-data-access.R +++ b/tests/testthat/tests-get_file_metadata.R @@ -19,20 +19,3 @@ test_that("get file metadata from file id", { expect_true(is.character(actual)) expect_true(4000 < nchar(actual)) # There should be 4k+ characters }) - -test_that("download file from DOI and filename", { - actual <- get_file( - file = "roster-bulls-1996.tab", - dataset = "doi:10.70122/FK2/FAN622" - ) - expect_true(is.raw(actual)) - expect_true(1000 < object.size(actual)) # Should be 1+ KB -}) - -test_that("download file from file id", { - actual <- get_file( - file = 396357 - ) - expect_true(is.raw(actual)) - expect_true(1000 < object.size(actual)) # Should be 1+ KB -})