Skip to content

Commit

Permalink
test: avoid snapshot dplyr tests for post_array 🧪
Browse files Browse the repository at this point in the history
  • Loading branch information
loreabad6 committed Sep 6, 2024
1 parent dc89fb7 commit 36f86e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 121 deletions.
114 changes: 0 additions & 114 deletions tests/testthat/_snaps/dplyr.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,117 +210,3 @@
1 a 2020-10-02 ((0.4961102 0.8728385, 0.4361026 0.947795, 0.5006209 1.09664~
2 a 2020-10-03 ((0.5578801 0.8616378, 0.5623908 1.085448, 0.8520717 0.89819~

# filter works as expected and returns a post_array

Code
out1
Output
stars object with 2 dimensions and 1 attribute
attribute(s):
geometry
POLYGON :5
epsg:4326 :0
+proj=long...:0
dimension(s):
from to refsys point
geom_sum 1 5 WGS 84 TRUE
datetime 1 1 Date FALSE
values
geom_sum POINT (0.647816 0.9018588),...,POINT (0.4690683 0.17772)
datetime 2020-10-03

# mutate works as expected and returns a post_array

Code
out1
Output
stars object with 2 dimensions and 2 attributes
attribute(s):
geometry foo
POLYGON :25 Length:25
epsg:4326 : 0 Class :character
+proj=long...: 0 Mode :character
dimension(s):
from to offset delta refsys point
geom_sum 1 5 NA NA WGS 84 TRUE
datetime 1 5 2020-10-01 1 days Date FALSE
values
geom_sum POINT (0.647816 0.9018588),...,POINT (0.4690683 0.17772)
datetime NULL

# rename works as expected and returns a post_array

Code
out1
Output
stars object with 2 dimensions and 1 attribute
attribute(s):
foo
POLYGON :25
epsg:4326 : 0
+proj=long...: 0
dimension(s):
from to offset delta refsys point
geom_sum 1 5 NA NA WGS 84 TRUE
datetime 1 5 2020-10-01 1 days Date FALSE
values
geom_sum POINT (0.647816 0.9018588),...,POINT (0.4690683 0.17772)
datetime NULL

# select works as expected and returns a post_array

Code
out1
Output
stars object with 2 dimensions and 1 attribute
attribute(s):
geometry
POLYGON :25
epsg:4326 : 0
+proj=long...: 0
dimension(s):
from to offset delta refsys point
geom_sum 1 5 NA NA WGS 84 TRUE
datetime 1 5 2020-10-01 1 days Date FALSE
values
geom_sum POINT (0.647816 0.9018588),...,POINT (0.4690683 0.17772)
datetime NULL

# slice works as expected and returns a post_array

Code
out1
Output
stars object with 2 dimensions and 1 attribute
attribute(s):
geometry
POLYGON :10
epsg:4326 : 0
+proj=long...: 0
dimension(s):
from to offset delta refsys point
geom_sum 3 4 NA NA WGS 84 TRUE
datetime 1 5 2020-10-01 1 days Date FALSE
values
geom_sum POINT (0.3897 0.5412), POINT (0.7526 0.3538)
datetime NULL

# transmute works as expected and returns a post_array

Code
out1
Output
stars object with 2 dimensions and 2 attributes
attribute(s):
foo geometry
Length:25 POLYGON :25
Class :character epsg:4326 : 0
Mode :character +proj=long...: 0
dimension(s):
from to offset delta refsys point
geom_sum 1 5 NA NA WGS 84 TRUE
datetime 1 5 2020-10-01 1 days Date FALSE
values
geom_sum POINT (0.647816 0.9018588),...,POINT (0.4690683 0.17772)
datetime NULL

14 changes: 7 additions & 7 deletions tests/testthat/test-dplyr.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,37 +79,37 @@ cls_arr = c("post_array")
test_that("filter works as expected and returns a post_array", {
skip_if_not_installed("cubelyr")
out1 = filter(arr, datetime == "2020-10-03")
expect_snapshot(out1)
expect_equal(length(out1$geometry), 5)
expect_s3_class(out1, cls_arr)
})
test_that("mutate works as expected and returns a post_array", {
out1 = mutate(arr, foo = "bar")
expect_snapshot(out1)
expect_equal(names(out1), c("geometry", "foo"))
expect_s3_class(out1, cls_arr)
})
test_that("rename works as expected and returns a post_array", {
out1 = rename(arr, foo = "geometry")
expect_snapshot(out1)
expect_equal(names(out1), "foo")
expect_s3_class(out1, cls_arr)
})
test_that("rename updates sf_column in post_array", {
expect_equal(attr(rename(arr, foo = "geometry"), "sf_column"), "foo")
})
test_that("select works as expected and returns a post_array", {
out1 = select(arr, -1)
expect_snapshot(out1)
out1 = select(mutate(arr, foo = "bar", apple = 2), foo)
expect_equal(names(out1), c("foo", "geometry"))
expect_s3_class(out1, cls_arr)
})
test_that("slice works as expected and returns a post_array", {
out1 = slice(arr, "geom_sum", 3:4)
expect_snapshot(out1)
expect_equal(length(out1$geometry), 10)
expect_s3_class(out1, cls_arr)
})
test_that("slice updates group_ids in post_array", {
expect_equal(attr(slice(arr, "geom_sum", 3:4), "group_ids"), c("c", "d"))
})
test_that("transmute works as expected and returns a post_array", {
out1 = transmute(arr, foo = "bar")
expect_snapshot(out1)
expect_equal(names(out1), c("foo", "geometry"))
expect_s3_class(out1, cls_arr)
})

0 comments on commit 36f86e2

Please sign in to comment.