Skip to content

Commit

Permalink
see whether errors are caused by the file already existing
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-smart88 committed Jul 25, 2024
1 parent 77dd1e5 commit 6acfa2e
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/testthat.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ library(testthat)
library(disagapp)
library(shinytest2)

#test_check("disagapp")
test_check("disagapp")
6 changes: 6 additions & 0 deletions tests/testthat/test-agg_uniform.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ test_that("{shinytest2} recording: e2e_agg_uniform", {

app$click("agg_uniform-run")

if (is_ci){
save_path <- tempfile(fileext = ".rds")
} else {
save_path <- "~/temprds/saved_file.rds"
}

app$set_inputs(main = "Save")
save_file <- app$get_download("core_save-save_session", filename = save_path)
common <- readRDS(save_file)
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-agg_upload.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ test_that("{shinytest2} recording: e2e_agg_upload", {
app$upload_file("agg_upload-agg" = aggdf$datapath)
app$click("agg_upload-run")

if (is_ci){
save_path <- tempfile(fileext = ".rds")
} else {
save_path <- "~/temprds/saved_file.rds"
}

app$set_inputs(main = "Save")
save_file <- app$get_download("core_save-save_session", filename = save_path)
common <- readRDS(save_file)
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-agg_worldpop.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ test_that("{shinytest2} recording: e2e_agg_worldpop", {
app$click(selector = "#agg_worldpop-run")
app$wait_for_value(input = "agg_worldpop-complete")

if (is_ci){
save_path <- tempfile(fileext = ".rds")
} else {
save_path <- "~/temprds/saved_file.rds"
}

app$set_inputs(main = "Save")
save_file <- app$get_download("core_save-save_session", filename = save_path)
common <- readRDS(save_file)
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-cov_access.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ test_that("{shinytest2} recording: e2e_cov_access", {
app$click(selector = "#cov_access-run")
app$wait_for_value(input = "cov_access-complete")

if (is_ci){
save_path <- tempfile(fileext = ".rds")
} else {
save_path <- "~/temprds/saved_file.rds"
}

app$set_inputs(main = "Save")
save_file <- app$get_download("core_save-save_session", filename = save_path)
common <- readRDS(save_file)
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-cov_bioclim.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ test_that("{shinytest2} recording: e2e_cov_bioclim", {
app$click(selector = "#cov_bioclim-run")
app$wait_for_value(input = "cov_bioclim-complete")

if (is_ci){
save_path <- tempfile(fileext = ".rds")
} else {
save_path <- "~/temprds/saved_file.rds"
}

app$set_inputs(main = "Save")
save_file <- app$get_download("core_save-save_session", filename = save_path)
common <- readRDS(save_file)
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-cov_landuse.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ test_that("{shinytest2} recording: e2e_cov_landuse", {
common <- app$get_value(export = "common")
expect_is(common$shape, "sf")

if (is_ci){
save_path <- tempfile(fileext = ".rds")
} else {
save_path <- "~/temprds/saved_file.rds"
}

app$set_inputs(main = "Save")
save_file <- app$get_download("core_save-save_session", filename = save_path)
common <- readRDS(save_file)
Expand Down
12 changes: 11 additions & 1 deletion tests/testthat/test-cov_upload.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,17 @@ test_that("{shinytest2} recording: e2e_cov_upload", {

app$upload_file("cov_upload-cov" = covdf$datapath)
app$click("cov_upload-run")
common <- app$get_value(export = "common")

if (is_ci){
save_path <- tempfile(fileext = ".rds")
} else {
save_path <- "~/temprds/saved_file.rds"
}

app$set_inputs(main = "Save")
save_file <- app$get_download("core_save-save_session", filename = save_path)
common <- readRDS(save_file)
common$covs <- unwrap_terra(common$covs)
expect_is(common$covs[[1]], "SpatRaster")
expect_equal(length(common$covs), 4)
})
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-resp_combine.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ test_that("{shinytest2} recording: e2e_resp_combine", {
app$set_inputs("resp_combine-shape_area_column" = shape_area_column)
app$click("resp_combine-run")

if (is_ci){
save_path <- tempfile(fileext = ".rds")
} else {
save_path <- "~/temprds/saved_file.rds"
}

app$set_inputs(main = "Save")
save_file <- app$get_download("core_save-save_session", filename = save_path)
common <- readRDS(save_file)
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-resp_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ test_that("{shinytest2} recording: e2e_resp_download", {
app$set_inputs("resp_download-admin" = "ADM1")
app$click("resp_download-run")

if (is_ci){
save_path <- tempfile(fileext = ".rds")
} else {
save_path <- "~/temprds/saved_file.rds"
}

app$set_inputs(main = "Save")
save_file <- app$get_download("core_save-save_session", filename = save_path)
common <- readRDS(save_file)
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-resp_edit.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ test_that("{shinytest2} recording: e2e_resp_shape", {
app$set_inputs("resp_edit-type" = "outside")
app$click("resp_edit-run")

if (is_ci){
save_path <- tempfile(fileext = ".rds")
} else {
save_path <- "~/temprds/saved_file.rds"
}

app$set_inputs(main = "Save")
save_file <- app$get_download("core_save-save_session", filename = save_path)
common <- readRDS(save_file)
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-resp_simplify.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ test_that("{shinytest2} recording: e2e_resp_simplify", {
app$set_inputs("resp_simplify-distance" = 1000)
app$click("resp_simplify-run")

if (is_ci){
save_path <- tempfile(fileext = ".rds")
} else {
save_path <- "~/temprds/saved_file.rds"
}

app$set_inputs(main = "Save")
save_file <- app$get_download("core_save-save_session", filename = save_path)
common <- readRDS(save_file)
Expand Down
21 changes: 21 additions & 0 deletions tests/testthat/test-save_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ test_that("{shinytest2} recording: e2e_empty_save", {
app <- shinytest2::AppDriver$new(app_dir = system.file("shiny", package = "disagapp"), name = "e2e_empty_save")
app$set_inputs(tabs = "resp")
app$set_inputs(main = "Save")

if (is_ci){
save_path <- tempfile(fileext = ".rds")
} else {
save_path <- "~/temprds/saved_file.rds"
}

save_file <- app$get_download("core_save-save_session", filename = save_path)
common <- readRDS(save_file)
expect_length(common$covs, 0)
Expand All @@ -25,6 +32,13 @@ test_that("{shinytest2} recording: e2e_shape_save", {
app$set_inputs("resp_shape-resp_var" = "inc")
app$click("resp_shape-run")
app$set_inputs(main = "Save")

if (is_ci){
save_path <- tempfile(fileext = ".rds")
} else {
save_path <- "~/temprds/saved_file.rds"
}

save_file <- app$get_download("core_save-save_session", filename = save_path)
common <- readRDS(save_file)
expect_is(common$shape, "sf")
Expand Down Expand Up @@ -56,6 +70,13 @@ test_that("{shinytest2} recording: e2e_settings_save", {
app$set_inputs("agg_worldpop-country" = "Liechtenstein")
app$set_inputs("agg_worldpop-resolution" = "100m")
app$set_inputs(main = "Save")

if (is_ci){
save_path <- tempfile(fileext = ".rds")
} else {
save_path <- "~/temprds/saved_file.rds"
}

save_file <- app$get_download("core_save-save_session", filename = save_path)
common <- readRDS(save_file)
expect_equal(common$state$resp_example$dataset, "scot")
Expand Down

0 comments on commit 6acfa2e

Please sign in to comment.