diff --git a/DESCRIPTION b/DESCRIPTION index 047eab6..02ab142 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: condathis Title: Run Any CLI Tool on a Conda Environment -Version: 0.0.7.9005 +Version: 0.0.7.9006 Authors@R: c( person("Lucio", "Queiroz", , "luciorqueiroz@gmail.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0002-6090-1834")), diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 68fc86f..6d5d3eb 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -18,5 +18,10 @@ withr::local_envvar( `APPDATA` = fs::path_temp("tmp", "home", "data"), `R_USER_DATA_DIR` = fs::path_temp("tmp", "home", "data"), `XDG_DATA_HOME` = fs::path_temp("tmp", "home", "data") - ) + ), + .local_envir = testthat::teardown_env() ) +if (isFALSE(fs::dir_exists(fs::path_temp("tmp", "home")))) { + fs::dir_create(fs::path_temp("tmp", "home")) +} + diff --git a/tests/testthat/test-check_connection.R b/tests/testthat/test-check_connection.R index 48db9d4..8d6abe6 100644 --- a/tests/testthat/test-check_connection.R +++ b/tests/testthat/test-check_connection.R @@ -1,7 +1,7 @@ test_that("GitHub is reachable", { testthat::skip_if_offline() - testthat::skip_on_ci() testthat::skip_on_cran() + testthat::skip_on_ci() github_url <- "https://github.com" con_res <- check_connection(url_to_check = github_url) diff --git a/tests/testthat/test-create_base_env.R b/tests/testthat/test-create_base_env.R index 6173461..e55f7ba 100644 --- a/tests/testthat/test-create_base_env.R +++ b/tests/testthat/test-create_base_env.R @@ -1,4 +1,7 @@ testthat::test_that("Create base env", { + testthat::skip_if_offline() + testthat::skip_on_cran() + if (fs::dir_exists(fs::path(get_install_dir(), "envs", "condathis-env"))) { fs::dir_delete(fs::path(get_install_dir(), "envs", "condathis-env")) } diff --git a/tests/testthat/test-create_env.R b/tests/testthat/test-create_env.R index bd0189e..0c2d5a0 100644 --- a/tests/testthat/test-create_env.R +++ b/tests/testthat/test-create_env.R @@ -23,6 +23,7 @@ testthat::test_that("create_env invalid method arg", { }) testthat::test_that("conda env is created", { + testthat::skip_if_offline() testthat::skip_on_cran() px_res <- create_env( @@ -144,6 +145,7 @@ testthat::test_that("conda env is created", { }) testthat::test_that("Create conda env from file", { + testthat::skip_if_offline() testthat::skip_on_cran() px_res <- create_env( diff --git a/tests/testthat/test-create_nested_env.R b/tests/testthat/test-create_nested_env.R index f908d07..fe045a3 100644 --- a/tests/testthat/test-create_nested_env.R +++ b/tests/testthat/test-create_nested_env.R @@ -1,5 +1,7 @@ test_that("create nested environment", { + testthat::skip_if_offline() testthat::skip_on_cran() + create_res <- create_env( packages = NULL, env_name = "test-nested-env", diff --git a/tests/testthat/test-env_exists.R b/tests/testthat/test-env_exists.R index dd7b519..3a83618 100644 --- a/tests/testthat/test-env_exists.R +++ b/tests/testthat/test-env_exists.R @@ -1,4 +1,7 @@ test_that("env_exists missing env_name", { + testthat::skip_if_offline() + testthat::skip_on_cran() + expect_error(env_exists()) expect_equal(env_exists(NULL), FALSE) expect_equal(env_exists(NA), FALSE) diff --git a/tests/testthat/test-install_micromamba.R b/tests/testthat/test-install_micromamba.R index fd230d1..43e11e1 100644 --- a/tests/testthat/test-install_micromamba.R +++ b/tests/testthat/test-install_micromamba.R @@ -1,4 +1,5 @@ test_that("Micromamba installation", { + testthat::skip_if_offline() testthat::skip_on_cran() withr::local_path(new = list(), action = "replace") umamba_bin_path <- install_micromamba(force = FALSE) @@ -6,6 +7,7 @@ test_that("Micromamba installation", { }) test_that("Micromamba already installed", { + testthat::skip_if_offline() testthat::skip_on_cran() testthat::expect_message( object = { diff --git a/tests/testthat/test-is_micromamba_available_for_arch.R b/tests/testthat/test-is_micromamba_available_for_arch.R index 447f6ca..7e4daaf 100644 --- a/tests/testthat/test-is_micromamba_available_for_arch.R +++ b/tests/testthat/test-is_micromamba_available_for_arch.R @@ -1,6 +1,4 @@ # tests/testthat/test-is_micromamba_available_for_arch.R -library(testthat) - test_that("is_micromamba_available_for_arch handles custom sys_arch input correctly", { # Test case for Linux-x86_64 expect_equal(is_micromamba_available_for_arch("Linux-x86_64"), "linux-64") diff --git a/tests/testthat/test-list_packages.R b/tests/testthat/test-list_packages.R index 7335ae0..36255ac 100644 --- a/tests/testthat/test-list_packages.R +++ b/tests/testthat/test-list_packages.R @@ -1,4 +1,7 @@ test_that("list packages on absent environment", { + testthat::skip_if_offline() + testthat::skip_on_cran() + testthat::expect_error( object = { list_packages(env_name = "non-existing-env") diff --git a/tests/testthat/test-native_cmd.R b/tests/testthat/test-native_cmd.R index c4281b4..9049107 100644 --- a/tests/testthat/test-native_cmd.R +++ b/tests/testthat/test-native_cmd.R @@ -1,4 +1,7 @@ test_that("Native run conda command", { + testthat::skip_if_offline() + testthat::skip_on_cran() + px_res <- native_cmd("--help", verbose = FALSE) expect_equal( object = px_res$status, diff --git a/tests/testthat/test-parse_strategy_verbose.R b/tests/testthat/test-parse_strategy_verbose.R index 7944269..06275dd 100644 --- a/tests/testthat/test-parse_strategy_verbose.R +++ b/tests/testthat/test-parse_strategy_verbose.R @@ -9,7 +9,5 @@ testthat::test_that("Parse verbose strategy", { parse_strategy_verbose("TRUE"), class = "condathis_error_invalid_verbose" ) - - testthat::expect_equal(parse_strategy_verbose(strategy = c("silent", " full")), list(cmd = FALSE, output = FALSE)) }) diff --git a/tests/testthat/test-run_output_file.R b/tests/testthat/test-run_output_file.R index a51f1cb..898e5fd 100644 --- a/tests/testthat/test-run_output_file.R +++ b/tests/testthat/test-run_output_file.R @@ -1,8 +1,9 @@ -library(testthat) - -create_env(env_name = "condathis-test-env", verbose = FALSE) +# create_env(env_name = "condathis-test-env", verbose = FALSE) test_that("Output redirection to file", { + testthat::skip_if_offline() + testthat::skip_on_cran() + create_env(env_name = "condathis-test-env", verbose = "silent") temp_output_file <- fs::file_temp("test_output", ext = "txt") px_res <- run( @@ -23,9 +24,9 @@ test_that("Output redirection to file", { NULL ) fs::file_delete(temp_output_file) -}) + # }) -test_that("Internal output", { + # test_that("Internal output", { px_res <- run( "echo", "Hello World!", env_name = "condathis-test-env", @@ -39,9 +40,9 @@ test_that("Internal output", { testthat::expect_true( object = stringr::str_detect(px_res$stdout, "Hello World!"), ) -}) + # }) -test_that("Error/warning redirection to file", { + # test_that("Error/warning redirection to file", { temp_output_file <- fs::file_temp("test_stderr", ext = "txt") px_res <- run( "ls", "-lah", "MissingFILE", @@ -61,7 +62,9 @@ test_that("Error/warning redirection to file", { NULL ) fs::file_delete(temp_output_file) + remove_env(env_name = "condathis-test-env", verbose = FALSE) }) +# remove_env(env_name = "condathis-test-env", verbose = FALSE) + -remove_env(env_name = "condathis-test-env", verbose = FALSE)