diff --git a/tests/testthat/projects/falsy-bitbucket/deps.R b/tests/testthat/projects/falsy-github/deps.R similarity index 100% rename from tests/testthat/projects/falsy-bitbucket/deps.R rename to tests/testthat/projects/falsy-github/deps.R diff --git a/tests/testthat/projects/falsy-github/packrat/packrat.lock b/tests/testthat/projects/falsy-github/packrat/packrat.lock new file mode 100644 index 00000000..617d26fe --- /dev/null +++ b/tests/testthat/projects/falsy-github/packrat/packrat.lock @@ -0,0 +1,18 @@ +PackratFormat: 1.4 +PackratVersion: 0.5.0.11 +RVersion: 3.5.1 +Repos: CRAN=https://cran.rstudio.com/ + +Package: falsy +Source: github +Version: 1.0.1 +Hash: cd9f70fd26fa58a4b3070370b16b8660 +GithubRepo: falsy +GithubUsername: cran +GithubRef: master +GithubSha1: 26a36cf957a18569e311ef75b6f61f822de945ef +RemoteHost: api.github.com +RemoteRepo: falsy +RemoteUsername: cran +RemoteRef: master +RemoteSha: 26a36cf957a18569e311ef75b6f61f822de945ef diff --git a/tests/testthat/projects/skeleton-bitbucket/deps.R b/tests/testthat/projects/skeleton-bitbucket/deps.R new file mode 100644 index 00000000..d37a0016 --- /dev/null +++ b/tests/testthat/projects/skeleton-bitbucket/deps.R @@ -0,0 +1 @@ +library(skeleton) diff --git a/tests/testthat/projects/falsy-bitbucket/packrat/packrat.lock b/tests/testthat/projects/skeleton-bitbucket/packrat/packrat.lock similarity index 65% rename from tests/testthat/projects/falsy-bitbucket/packrat/packrat.lock rename to tests/testthat/projects/skeleton-bitbucket/packrat/packrat.lock index 141bccc5..da1bbfd5 100644 --- a/tests/testthat/projects/falsy-bitbucket/packrat/packrat.lock +++ b/tests/testthat/projects/skeleton-bitbucket/packrat/packrat.lock @@ -3,12 +3,12 @@ PackratVersion: 0.5.0.11 RVersion: 3.5.1 Repos: CRAN=https://cran.rstudio.com/ -Package: falsy +Package: skeleton Source: bitbucket Version: 1.0.1 Hash: 97013d7da058d0be0595621449505494 -RemoteRepo: falsy -RemoteUsername: rstudio_official +RemoteRepo: skeleton +RemoteUsername: kevinushey RemoteRef: master -RemoteSha: 26a36cf957a18569e311ef75b6f61f822de945ef +RemoteSha: 958296dbbbf7f1d82f7f5dd1b121c7558604809f RemoteHost: api.bitbucket.org/2.0 diff --git a/tests/testthat/test-packrat.R b/tests/testthat/test-packrat.R index 1ae6be35..d3278bfe 100644 --- a/tests/testthat/test-packrat.R +++ b/tests/testthat/test-packrat.R @@ -354,14 +354,22 @@ withTestContext({ test_that("Packages restored from GitLab have RemoteType+RemoteHost in their DESCRIPTION", { skip_on_cran() + skip_if_offline() skip_on_os("windows") # Windows tar.exe fails to extract the archive received here. projRoot <- cloneTestProject("falsy-gitlab") # ignore R version warnings suppressWarnings(restore(projRoot)) + lib <- libDir(projRoot) + + # verify the package was installed and can be loaded + expect_true(file.exists(file.path(lib, "falsy"))) + expect_true(requireNamespace("falsy", lib.loc = lib)) + on.exit(unloadNamespace("falsy"), add = TRUE) + # validate the installed package has properly annotated DESCRIPTION - descpath <- file.path(libDir(projRoot), "falsy/DESCRIPTION") + descpath <- file.path(lib, "falsy/DESCRIPTION") desc <- as.data.frame(readDcf(descpath)) expect_true(desc$RemoteType == "gitlab") expect_true(desc$RemoteHost == "gitlab.com") @@ -373,13 +381,21 @@ withTestContext({ test_that("Packages restored from BitBucket have RemoteType+RemoteHost in their DESCRIPTION", { skip_on_cran() - projRoot <- cloneTestProject("falsy-bitbucket") + skip_if_offline() + projRoot <- cloneTestProject("skeleton-bitbucket") # ignore R version warnings suppressWarnings(restore(projRoot)) + lib <- libDir(projRoot) + + # verify the package was installed and can be loaded + expect_true(file.exists(file.path(lib, "skeleton"))) + expect_true(requireNamespace("skeleton", lib.loc = lib)) + on.exit(unloadNamespace("skeleton"), add = TRUE) + # validate the installed package has properly annotated DESCRIPTION - descpath <- file.path(libDir(projRoot), "falsy/DESCRIPTION") + descpath <- file.path(lib, "skeleton/DESCRIPTION") desc <- as.data.frame(readDcf(descpath)) expect_true(desc$RemoteType == "bitbucket") expect_true(desc$RemoteHost == "api.bitbucket.org/2.0") @@ -392,6 +408,33 @@ withTestContext({ expect_false("remote_subdir" %in% names(record)) }) + test_that("Packages restored from GitHub have GithubRepo+GithubSHA1 in their DESCRIPTION", { + skip_on_cran() + skip_if_offline() + projRoot <- cloneTestProject("falsy-github") + + suppressWarnings(restore(projRoot)) + + lib <- libDir(projRoot) + + # verify the package was installed and can be loaded + expect_true(file.exists(file.path(lib, "falsy"))) + expect_true(requireNamespace("falsy", lib.loc = lib)) + on.exit(unloadNamespace("falsy"), add = TRUE) + + # validate the installed package has properly annotated DESCRIPTION + descpath <- file.path(lib, "falsy/DESCRIPTION") + desc <- as.data.frame(readDcf(descpath)) + expect_equal(desc$RemoteType, "github") + expect_equal(desc$GithubRepo, "falsy") + expect_equal(desc$GithubUsername, "cran") + expect_equal(desc$GithubSHA1, "26a36cf957a18569e311ef75b6f61f822de945ef") + + # confirm that packrat interprets this package as coming from github + record <- inferPackageRecord(desc) + expect_equal(record$source, "github") + }) + test_that("packrat and remotes annotated descriptions are comparable", { remotesDesc <- as.data.frame(readDcf( "resources/descriptions/falsy.remotes"