Skip to content

Commit

Permalink
Parse created and modified dates
Browse files Browse the repository at this point in the history
  • Loading branch information
Moohan committed Apr 19, 2024
1 parent 2985f44 commit 8c74ee9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions R/add_context.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions tests/testthat/test-get_resource_context.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 8c74ee9

Please sign in to comment.