diff --git a/R/add_context.R b/R/add_context.R index 57f00bc..2272089 100644 --- a/R/add_context.R +++ b/R/add_context.R @@ -4,6 +4,10 @@ add_context <- function(data, id, name, created_date, modified_date) { modified_date <- NA_character_ } + # Parse the date values + created_date <- strptime(created_date, format = "%FT%X", tz = "UTC") + modified_date <- strptime(modified_date, format = "%FT%X", tz = "UTC") + data_with_context <- dplyr::mutate( data, "res_id" = id, diff --git a/tests/testthat/test-get_resource_context.R b/tests/testthat/test-get_resource_context.R index e9a922f..504855c 100644 --- a/tests/testthat/test-get_resource_context.R +++ b/tests/testthat/test-get_resource_context.R @@ -7,13 +7,18 @@ test_that("returns expected context with the data", { # without query data <- get_resource( res_id = gp_list_apr_2021, - rows = 1, + rows = 10, include_context = TRUE ) expect_s3_class(data, "tbl_df") + expect_type(data$res_id, "character") + expect_type(data$res_name, "character") + expect_s3_class(data$res_created_date, "POSIXlt") + expect_s3_class(data$res_modified_date, "POSIXlt") + expect_length(data, 19) - expect_equal(nrow(data), 1) + expect_equal(nrow(data), 10) expect_named(data, c( "res_id", "res_name",