diff --git a/DESCRIPTION b/DESCRIPTION index c959a5c..c2730bd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -43,7 +43,7 @@ Suggests: readr (>= 1.3.1), rmarkdown (>= 1.12), rstudioapi (>= 0.10), - testthat (>= 2.1.1), + testthat (>= 3.0.0), tidyr (>= 0.8.3), pkgdown (>= 2.0.3) VignetteBuilder: @@ -56,3 +56,4 @@ Roxygen: list(markdown = TRUE) RoxygenNote: 7.1.2 URL: https://github.com/ixpantia/ixplorer BugReports: https://github.com/ixpantia/ixplorer/issues +Config/testthat/edition: 3 diff --git a/R/credential_cache.R b/R/credential_cache.R index bba51a1..db73cbd 100644 --- a/R/credential_cache.R +++ b/R/credential_cache.R @@ -16,13 +16,11 @@ #' @export set_git_credentials_cache <- function(hours = 4, global = TRUE) { -if (global == TRUE) { - system(paste( - "git config --global credential.helper cache --timeout=", - hours * 60 * 60, "'"), show.output.on.console = FALSE) + if (global == TRUE) { + system(paste0('git config --global credential.helper --replace-all "cache --timeout=', + hours * 60 * 60, '"')) } else { - system(paste( - "git config credential.helper cache --timeout=", - hours * 60 * 60, "'"), show.output.on.console = FALSE) + system(paste0('git config credential.helper "cache --timeout=', + hours * 60 * 60, '"')) } } diff --git a/R/git.R b/R/git.R index b50f88c..4424f5e 100644 --- a/R/git.R +++ b/R/git.R @@ -101,9 +101,11 @@ incluye_upstream <- function(instancia = "guardada") { set_git_timeout <- function(timeout = 14400, global = FALSE) { if (global == TRUE) { - instruction <- paste0("git config --global credential.helper cache --timeout=", timeout) + instruction <- paste0('git config --global credential.helper --replace-all "cache --timeout=', + timeout, '"') } else { - instruction <- paste0("git config credential.helper cache --timeout=", timeout) + instruction <- paste0('git config credential.helper "cache --timeout=', + timeout, '"') } system(instruction) @@ -133,7 +135,7 @@ set_git_timeout <- function(timeout = 14400, global = FALSE) { #' @param global si el cambio debe ser global o local para el repositorio #' #' @export -fijar_tiempo_credenciales <- function(pausa = 14000, global = FALSE) { +fijar_tiempo_credenciales <- function(pausa = 14400, global = FALSE) { if (global == FALSE) { set_git_timeout(timeout = pausa, global = FALSE) diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..0805668 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,4 @@ +library(testthat) +library(ixplorer) + +test_check("ixplorer") diff --git a/tests/testthat/tests.R b/tests/testthat/tests.R new file mode 100644 index 0000000..af81695 --- /dev/null +++ b/tests/testthat/tests.R @@ -0,0 +1,12 @@ +library(testthat) +library(ixplorer) + + +testthat::test_that("git commands are well executed", { + testthat::expect_silent(set_git_credentials_cache(global = TRUE, hours = 6)) + testthat::expect_silent(set_git_credentials_cache(global = FALSE, hours = 8)) + testthat::expect_silent(ixplorer::set_git_timeout(timeout = 14403, global = TRUE)) + testthat::expect_silent(ixplorer::set_git_timeout(timeout = 14403, global = FALSE)) + testthat::expect_silent(ixplorer::fijar_tiempo_credenciales(pausa = 14404, global = FALSE)) + testthat::expect_silent(ixplorer::fijar_tiempo_credenciales(pausa = 14405, global = TRUE)) +})