Skip to content

Commit

Permalink
test: unit tests for set_version()
Browse files Browse the repository at this point in the history
  • Loading branch information
ahasverus committed Feb 14, 2024
1 parent 6496956 commit 28a7fec
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/testthat/test-version.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,43 @@ test_that("Test get_current_version() for success", {


## set_version() ----

test_that("Test set_version() for error", {

expect_error(set_version(version = "999", ask = FALSE),
paste0("The required version is not available. Please run ",
"'get_available_versions()' to list available versions."),
fixed = TRUE)
})

test_that("Test set_version() for success", {

create_tempdir()

y <- get_latest_version()
x <- set_version(version = NULL, ask = FALSE)

expect_equal(class(x), "character")
expect_equal(length(x), 1L)
expect_equal(x, y)
expect_true(file.exists(".forcis"))
})

test_that("Test set_version() for success", {

create_tempdir()

x <- set_version(version = "07", ask = FALSE)

expect_equal(class(x), "character")
expect_equal(length(x), 1L)
expect_equal(x, "07")
expect_true(file.exists(".forcis"))

x <- set_version(version = NULL, ask = FALSE)

expect_equal(class(x), "character")
expect_equal(length(x), 1L)
expect_equal(x, "07")
expect_true(file.exists(".forcis"))
})

0 comments on commit 28a7fec

Please sign in to comment.