From 36f86e229765211252fbd84ec389bc501863e939 Mon Sep 17 00:00:00 2001 From: loreabad6 Date: Fri, 6 Sep 2024 12:11:52 +0200 Subject: [PATCH] test: avoid snapshot dplyr tests for post_array :test_tube: --- tests/testthat/_snaps/dplyr.md | 114 --------------------------------- tests/testthat/test-dplyr.R | 14 ++-- 2 files changed, 7 insertions(+), 121 deletions(-) diff --git a/tests/testthat/_snaps/dplyr.md b/tests/testthat/_snaps/dplyr.md index fb1e76d..ba02350 100644 --- a/tests/testthat/_snaps/dplyr.md +++ b/tests/testthat/_snaps/dplyr.md @@ -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 - diff --git a/tests/testthat/test-dplyr.R b/tests/testthat/test-dplyr.R index 0b3b67c..3c77d26 100644 --- a/tests/testthat/test-dplyr.R +++ b/tests/testthat/test-dplyr.R @@ -79,30 +79,30 @@ 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", { @@ -110,6 +110,6 @@ test_that("slice updates group_ids in post_array", { }) 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) })