jonkeane commented on a change in pull request #12357:
URL: https://github.com/apache/arrow/pull/12357#discussion_r804245782



##########
File path: r/tests/testthat/test-dplyr-funcs-datetime.R
##########
@@ -711,3 +711,37 @@ test_that("am/pm mirror lubridate", {
   )
 
 })
+
+test_that("extract tz", {
+  df <- tibble(
+    x = as.POSIXct(c("2022-02-07", "2022-02-10"), tz = "Pacific/Marquesas"),
+    # lubridate::tz() returns -for the time being - "UTC" for NAs, strings,
+    # dates and numerics
+    y = c("2022-02-07", NA),
+    z = as.Date(c("2022-02-07", NA)),
+    w = c(1L, 5L),
+    v = c(1.1, 2.47)
+  )
+
+  compare_dplyr_binding(
+    .input %>%
+      mutate(timezone_x = tz(x)) %>%
+      collect(),
+    df
+  )
+
+  expect_snapshot(
+    compare_dplyr_binding(
+      .input %>%
+        mutate(
+          timezone_y = tz(x),
+          timezone_z = tz(z),
+          timezone_w = tz(w),
+          timezone_v = tz(v)
+        ) %>%
+        collect(),
+      df
+    ),
+    error = TRUE
+  )

Review comment:
       If we're testing our package's error messages (and those message or the 
behavior is different from dplyr's or lubridate's), we should do that outside 
of `compare_dplyr_binding()` since there's not really an output to compare to 
(one example: 
https://github.com/apache/arrow/blob/fa699117091917f0992225aff4e8d4c08910162a/r/tests/testthat/test-dplyr-funcs-string.R#L939-L948)
   
   or if the behavior was different, the results aren't exactly the same, 
example: 
https://github.com/apache/arrow/blob/fa699117091917f0992225aff4e8d4c08910162a/r/tests/testthat/test-dplyr-funcs-string.R#L236-L255




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to