Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/testthat/projects/falsy-github/packrat/packrat.lock
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions tests/testthat/projects/skeleton-bitbucket/deps.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
library(skeleton)
Original file line number Diff line number Diff line change
Expand Up @@ -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
49 changes: 46 additions & 3 deletions tests/testthat/test-packrat.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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"
Expand Down
Loading