Skip to content

Commit

Permalink
deleteStudy() : add API condition
Browse files Browse the repository at this point in the history
  • Loading branch information
boitardn committed Jan 16, 2024
1 parent 3b7b17b commit 8330039
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions R/createStudy.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,12 @@ createStudyAPI <- function(host, token = NULL, study_name = "my_study", antares_
#' @importFrom antaresRead api_delete
#' @export
deleteStudy <- function(opts = simOptions(), prompt_validation = FALSE, simulation = NULL){


res <- NULL
delete_simulation <- !is.null(simulation)
is_api_study <- is_api_study(opts)

if(!file.exists(opts$studyPath)){ stop("Study not found.") }
if(!is_api_study && !file.exists(opts$studyPath)){ stop("Study not found.") }

Check warning on line 128 in R/createStudy.R

View check run for this annotation

Codecov / codecov/patch

R/createStudy.R#L128

Added line #L128 was not covered by tests

if(prompt_validation){
if(delete_simulation){
Expand All @@ -139,7 +140,10 @@ deleteStudy <- function(opts = simOptions(), prompt_validation = FALSE, simulati
}

prompt_answer <- menu(c("Yes", "No"),title=prompt_question)
if (prompt_answer == 2){ return() }
if (prompt_answer == 2){
res <- opts
return(res)

Check warning on line 145 in R/createStudy.R

View check run for this annotation

Codecov / codecov/patch

R/createStudy.R#L142-L145

Added lines #L142 - L145 were not covered by tests
}
}

if(is_api_study & delete_simulation){
Expand All @@ -160,7 +164,6 @@ deleteStudy <- function(opts = simOptions(), prompt_validation = FALSE, simulati
unlink(path, recursive = TRUE)
}

res <- NULL
if(is_api_study(opts)){ res <- update_opts(opts) }

Check warning on line 167 in R/createStudy.R

View check run for this annotation

Codecov / codecov/patch

R/createStudy.R#L167

Added line #L167 was not covered by tests

cat(sprintf("\n%s successfully deleted",
Expand Down

0 comments on commit 8330039

Please sign in to comment.