Skip to content

Commit

Permalink
not log for test with mock
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxo-m committed Aug 7, 2016
1 parent b89f814 commit be2edcd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
17 changes: 12 additions & 5 deletions R/gh_install_packages.R
Expand Up @@ -25,7 +25,6 @@
#' githubinstall("AnomalyDetection")
#' }
#'
#' @importFrom devtools install_github
#'
#' @rdname githubinstall
#'
Expand Down Expand Up @@ -73,10 +72,9 @@ gh_install_packages <- function(packages, ask = TRUE, ref = "master",
for (i in seq_along(repos)) {
repo <- repos[i]
ref <- references[i]
results[[i]] <- install_github(repo = repo, ref = ref, quiet = quiet,
dependencies = dependencies,
build_vignettes = build_vignettes, ... = ...)
log_installed_packages(repos = repo, ref = ref)
results[[i]] <- install_package(repo = repo, ref = ref, quiet = quiet,
dependencies = dependencies,
build_vignettes = build_vignettes, ... = ...)
}
.libPaths(lib_paths)
names(results) <- repos
Expand All @@ -87,6 +85,15 @@ gh_install_packages <- function(packages, ask = TRUE, ref = "master",
}
}

#' @importFrom devtools install_github
install_package <- function() {
result <- install_github(repo = repo, ref = ref, quiet = quiet,
dependencies = dependencies,
build_vignettes = build_vignettes, ... = ...)
log_installed_packages(repos = repo, ref = ref)
result
}

select_dependencies <- function(ask, build_vignettes, dependencies, quiet) {
if (build_vignettes && is.na(dependencies)) {
msg <- "We recommend to specify the 'dependencies' argument when 'build_vignettes' is TRUE."
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-gh_install_packages.R
@@ -1,13 +1,13 @@
context("Install packages")

install_github_mock <- function(...) {
install_package_mock <- function(...) {
list(...)
}

test_that("Install a single package", {
repo <- "AnomalyDetection"
with_mock(
`devtools::install_github` = install_github_mock,
`githubinstall:::install_package` = install_package_mock,
act <- gh_install_packages(repo, ask = FALSE)
)
expect_equal(act$repo, "twitter/AnomalyDetection")
Expand All @@ -16,7 +16,7 @@ test_that("Install a single package", {
test_that("Install two package", {
repo <- c("AnomalyDetection", "toybayesopt")
with_mock(
`devtools::install_github` = install_github_mock,
`githubinstall:::install_package` = install_package_mock,
act <- gh_install_packages(repo, ask = FALSE)
)
expect_equal(length(act), 2)
Expand Down

0 comments on commit be2edcd

Please sign in to comment.