Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Adafede committed Jul 3, 2024
1 parent b93609e commit 19391bb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
26 changes: 15 additions & 11 deletions R/install_latest_version.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
#'
#' @description This function installs the latest version
#'
#' @param test Flag for test
#'
#' @return NULL
#'
#' @export
#'
#' @examples NULL
install_latest_version <- function() {
install_latest_version <- function(test = FALSE) {
options(repos = c(CRAN = "https://cloud.r-project.org"))
if (Sys.info()[["sysname"]] == "Windows") {
message("You should install RTools if not already done")
Expand Down Expand Up @@ -55,17 +57,19 @@ install_latest_version <- function() {
ask = FALSE
)
},
error = function(err) {
if (Sys.getenv("RSTUDIO") == 1) {
if (!requireNamespace("rstudioapi", quietly = TRUE)) {
install.packages("rstudioapi")
}
rstudioapi::restartSession()
} else {
if (!requireNamespace("startup", quietly = TRUE)) {
install.packages("startup")
error = function(e) {
if (test == FALSE) {
if (Sys.getenv("RSTUDIO") == 1) {
if (!requireNamespace("rstudioapi", quietly = TRUE)) {
install.packages("rstudioapi")
}
rstudioapi::restartSession()
} else {
if (!requireNamespace("startup", quietly = TRUE)) {
install.packages("startup")
}
startup::restart()
}
startup::restart()
}
}
)
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@
"SystemRequirements": null
},
"keywords": ["metaboliteannotation", "chemotaxonomy", "scoringsystem", "naturalproducts", "computationalmetabolomics", "taxonomicdistance", "specializedmetabolome"],
"fileSize": "4377.05KB",
"fileSize": "4377.249KB",
"citation": [
{
"@type": "ScholarlyArticle",
Expand Down
5 changes: 4 additions & 1 deletion man/install_latest_version.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library(testthat)
## need to do all in one because of outputs needed in the same temp dir
## use fixtures instead in the future
test_that("Test functions", {
install_latest_version()
install_latest_version(test = TRUE)
setwd(fs::path_home(".tima"))
## Prepare parameters
paths <- parse_yaml_paths()
Expand Down

0 comments on commit 19391bb

Please sign in to comment.