diff --git a/DESCRIPTION b/DESCRIPTION index d88ce21..60dfe72 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: otndo Title: Understand your OTN data -Version: 0.3.0 +Version: 0.3.1 Authors@R: person("Michael", "O'Brien", , "mike@obrien.page", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1420-6395")) diff --git a/R/utilities_make.R b/R/utilities_make.R index 6806a79..53bfd0c 100644 --- a/R/utilities_make.R +++ b/R/utilities_make.R @@ -156,7 +156,7 @@ write_to_tempdir <- function(type, files, temp_dir) { ## Write file to temporary directory filepath <- file.path(temp_dir, paste0(type, ".csv")) - write.csv(files, filepath, + data.table::fwrite(files, filepath, row.names = F ) diff --git a/tests/testthat/test-write_to_tempdir.R b/tests/testthat/test-write_to_tempdir.R index ea3f2aa..7612eb3 100644 --- a/tests/testthat/test-write_to_tempdir.R +++ b/tests/testthat/test-write_to_tempdir.R @@ -1,7 +1,45 @@ test_that("writes and converts deployment data", { - skip("Test TBD") + deployment_filepath <- write_to_tempdir( + type = "deployment", + files = pbsm$deployment, + temp_dir = td + ) + + expect_true(file.exists(deployment_filepath)) + + + deployment <- data.table::fread(deployment_filepath) + + expect_named( + deployment, + c( + "stationname", "receiver", "internal_transmitter", "deploy_date_time", + "deploy_lat", "deploy_long", "recover_date_time" + ) + ) + + expect_s3_class( + deployment$deploy_date_time, + "POSIXct" + ) + expect_s3_class( + deployment$recover_date_time, + "POSIXct" + ) + + expect_type( + deployment$deploy_lat, + "double" + ) + + expect_type( + deployment$deploy_lon, + "double" + ) + }) + test_that("works with multiple deployment files", { skip("Test TBD") })