Skip to content

Commit

Permalink
cases for tests in couchdb-action
Browse files Browse the repository at this point in the history
  • Loading branch information
lsteinmann committed Nov 23, 2023
1 parent 7124746 commit 82aaa2c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## In general
* Better structure of tests with less specialized cases?
* Update the couch-db action a bit? See problems with _changes etc., and different configurations and contents.

## for v0.3.4 ?
* Handling geometry does not work very well and should be reconsidered. Maybe
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-idf_get_changes.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ skip_on_cran()

connection <- skip_if_no_connection()

check <- try(idf_last_changed(connection = connection, n = 5))
if (all(is.na(check))) {
skip("Test skipped, no changes recorded in 'rtest'-project database in this docker.")
} else if (inherits(check, "try-error")) {
skip(paste0("Test skipped, because of error: ", check))
}

index <- get_field_index(connection)

test_that("returns appropriate (number of) resources for UUID", {
Expand Down
17 changes: 11 additions & 6 deletions tests/testthat/test-idf_last_changed.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,21 @@ skip_on_cran()

connection <- skip_if_no_connection()

check <- idf_last_changed(connection = connection, n = 5)
check <- try(idf_last_changed(connection = connection, n = 5))
if (all(is.na(check))) {
skip("Test skipped, no changes recorded in 'rtest'-project database in this docker.")
} else if (inherits(check, "try-error")) {
skip(paste0("Test skipped, because of error: ", check))
}

test_that("message & NA on non-existing changes", {
connection$project <- "empty-db"
expect_message(res <- idf_last_changed(connection = connection), "_changes")
expect_true(is.na(res))
})
check <- try(idf_check_for_project(connection, project = "empty-db"))
if (!inherits(check, "try-error")) {
test_that("message & NA on non-existing changes", {
connection$project <- "empty-db"
expect_message(res <- idf_last_changed(connection = connection), "_changes")
expect_true(is.na(res))
})
}

index <- get_field_index(connection)

Expand Down

0 comments on commit 82aaa2c

Please sign in to comment.