| 1 |
|
| 2 |
test_that("we can parse a variety of remotes", { |
| 3 |
|
| 4 |
remote <- renv_remotes_parse("[email protected]:kevinushey/repo.git:subdir") |
| 5 |
expect_equal(remote$type, "git") |
| 6 |
expect_equal(remote$host, "github.com") |
| 7 |
expect_equal(remote$repo, "kevinushey/repo.git") |
| 8 |
expect_equal(remote$subdir, "subdir") |
| 9 |
|
| 10 |
remote <- renv_remotes_parse("url::https://github.com/kevinushey/renv.git1/archive/refs/heads/main.zip") |
| 11 |
expect_equal(remote$type, "url") |
| 12 |
expect_equal(remote$url, "https://github.com/kevinushey/renv.git1/archive/refs/heads/main.zip") |
| 13 |
expect_equal(remote$protocol, "https") |
| 14 |
|
| 15 |
# https://github.com/rstudio/renv/issues/1004 |
| 16 |
remote <- renv_remotes_parse("[email protected]:abc123/def456.git") |
| 17 |
expect_equal(remote$type, "git") |
| 18 |
expect_equal(remote$host, "github.com") |
| 19 |
expect_equal(remote$repo, "abc123/def456.git") |
| 20 |
|
| 21 |
# https://github.com/rstudio/renv/issues/667 |
| 22 |
remote <- renv_remotes_parse("[email protected]:abc123/def456.git") |
| 23 |
expect_equal(remote$package, "package") |
| 24 |
|
| 25 |
# https://github.com/rstudio/renv/issues/667 |
| 26 |
remote <- renv_remotes_parse("[email protected]:abc/def/ghi") |
| 27 |
expect_equal(remote$repo, "abc/def/ghi") |
| 28 |
|
| 29 |
}) |
| 30 |
|
| 31 |
test_that("we can parse a variety of remotes", { |
| 32 |
|
| 33 |
skip_on_cran() |
| 34 |
skip_if_no_github_auth() |
| 35 |
skip_on_os("windows") |
| 36 |
|
| 37 |
renv_tests_scope() |
| 38 |
|
| 39 |
# cran latest |
| 40 |
record <- renv_remotes_resolve("breakfast") |
| 41 |
expect_equal(record$Package, "breakfast") |
| 42 |
expect_equal(record$Version, NULL) |
| 43 |
|
| 44 |
# cran archive |
| 45 |
record <- renv_remotes_resolve("[email protected]") |
| 46 |
expect_equal(record$Package, "breakfast") |
| 47 |
expect_equal(record$Version, "0.1.0") |
| 48 |
|
| 49 |
# github master |
| 50 |
record <- renv_remotes_resolve("kevinushey/skeleton") |
| 51 |
expect_equal(record$Package, "skeleton") |
| 52 |
expect_equal(record$Version, "1.0.1") |
| 53 |
expect_equal(record$RemoteRef, "master") |
| 54 |
expect_equal(record$RemoteSha, "e4aafb92b86ba7eba3b7036d9d96fdfb6c32761a") |
| 55 |
|
| 56 |
# by commit |
| 57 |
record <- renv_remotes_resolve("kevinushey/skeleton@209c4e48e505e545ad7ab915904d983b5ab83b93") |
| 58 |
expect_equal(record$Package, "skeleton") |
| 59 |
expect_equal(record$Version, "1.0.0") |
| 60 |
expect_equal(record$RemoteSha, "209c4e48e505e545ad7ab915904d983b5ab83b93") |
| 61 |
|
| 62 |
# by branch |
| 63 |
record <- renv_remotes_resolve("kevinushey/skeleton@feature/version-bump") |
| 64 |
expect_equal(record$Package, "skeleton") |
| 65 |
expect_equal(record$Version, "1.0.2") |
| 66 |
expect_equal(record$RemoteRef, "feature/version-bump") |
| 67 |
expect_equal(record$RemoteSha, "86b5737411d3c6a6927dfcccd2c15a69284659fe") |
| 68 |
|
| 69 |
# by PR |
| 70 |
record <- renv_remotes_resolve("kevinushey/skeleton#1") |
| 71 |
expect_equal(record$Package, "skeleton") |
| 72 |
expect_equal(record$Version, "1.0.2") |
| 73 |
expect_equal(record$RemoteSha, "86b5737411d3c6a6927dfcccd2c15a69284659fe") |
| 74 |
|
| 75 |
# bitbucket |
| 76 |
record <- renv_remotes_resolve("bitbucket::kevinushey/skeleton") |
| 77 |
expect_equal(record$Package, "skeleton") |
| 78 |
expect_equal(record$Version, "1.0.1") |
| 79 |
expect_equal(record$RemoteHost, "api.bitbucket.org/2.0") |
| 80 |
expect_equal(record$RemoteRef, "master") |
| 81 |
expect_equal(record$RemoteSha, "958296dbbbf7f1d82f7f5dd1b121c7558604809f") |
| 82 |
|
| 83 |
# gitlab |
| 84 |
record <- renv_remotes_resolve("gitlab::kevinushey/skeleton") |
| 85 |
expect_equal(record$Package, "skeleton") |
| 86 |
expect_equal(record$Version, "1.0.1") |
| 87 |
expect_equal(record$RemoteHost, "gitlab.com") |
| 88 |
expect_equal(record$RemoteRef, "master") |
| 89 |
expect_equal(record$RemoteSha, "958296dbbbf7f1d82f7f5dd1b121c7558604809f") |
| 90 |
|
| 91 |
# git - https |
| 92 |
record <- renv_remotes_resolve("git::https://github.com/kevinushey/renv.git1.git@main") |
| 93 |
expect_equal(record$Package, "renv.git1") |
| 94 |
expect_equal(record$Version, "0.0.0.9000") |
| 95 |
expect_equal(record$RemoteUrl, "https://github.com/kevinushey/renv.git1.git") |
| 96 |
expect_equal(record$RemoteRef, "main") |
| 97 |
|
| 98 |
# git + *release |
| 99 |
record <- renv_remotes_resolve("kevinushey/skeleton@*release") |
| 100 |
expect_equal(record$Package, "skeleton") |
| 101 |
expect_equal(record$RemoteRef, "v1.0.1") |
| 102 |
|
| 103 |
# git + prefix |
| 104 |
record <- renv_remotes_resolve("skeleton=kevinushey/skeleton@*release") |
| 105 |
expect_equal(record$Package, "skeleton") |
| 106 |
expect_equal(record$RemoteRef, "v1.0.1") |
| 107 |
|
| 108 |
# url |
| 109 |
record <- renv_remotes_resolve("url::https://github.com/kevinushey/renv.git1/archive/refs/heads/main.zip") |
| 110 |
expect_equal(record$Package, "renv.git1") |
| 111 |
expect_equal(record$Version, "0.0.0.9000") |
| 112 |
expect_equal(record$RemoteUrl, "https://github.com/kevinushey/renv.git1/archive/refs/heads/main.zip") |
| 113 |
expect_equal(record$Source, "URL") |
| 114 |
|
| 115 |
# # git - ssh |
| 116 |
# # this test appears to fail on CI (ssh access to GitHub disallowed?) |
| 117 |
# record <- renv_remotes_resolve("git::[email protected]:kevinushey/renv.git1.git@main") |
| 118 |
# expect_equal(record$Package, "renv.git1") |
| 119 |
# expect_equal(record$Version, "0.0.0.9000") |
| 120 |
# expect_equal(record$RemoteUrl, "[email protected]:kevinushey/renv.git1.git") |
| 121 |
# expect_equal(record$RemoteRef, "main") |
| 122 |
|
| 123 |
# error |
| 124 |
expect_error(renv_remotes_resolve("can't parse this")) |
| 125 |
|
| 126 |
}) |
| 127 |
|
| 128 |
test_that("subdirectories are parsed in remotes", { |
| 129 |
|
| 130 |
spec <- "gitlab::user/repo:subdir@ref" |
| 131 |
remote <- renv_remotes_parse(spec) |
| 132 |
|
| 133 |
expected <- list( |
| 134 |
spec = spec, |
| 135 |
package = NULL, |
| 136 |
type = "gitlab", |
| 137 |
host = NULL, |
| 138 |
user = "user", |
| 139 |
repo = "repo", |
| 140 |
subdir = "subdir", |
| 141 |
pull = NULL, |
| 142 |
ref = "ref" |
| 143 |
) |
| 144 |
|
| 145 |
expect_equal(remote, expected) |
| 146 |
|
| 147 |
}) |
| 148 |
|
| 149 |
test_that("custom hosts can be supplied", { |
| 150 |
|
| 151 |
spec <- "gitlab@localhost::user/repo" |
| 152 |
remote <- renv_remotes_parse(spec) |
| 153 |
|
| 154 |
expected <- list( |
| 155 |
spec = spec, |
| 156 |
package = NULL, |
| 157 |
type = "gitlab", |
| 158 |
host = "localhost", |
| 159 |
user = "user", |
| 160 |
repo = "repo", |
| 161 |
subdir = NULL, |
| 162 |
pull = NULL, |
| 163 |
ref = NULL |
| 164 |
) |
| 165 |
|
| 166 |
expect_equal(remote, expected) |
| 167 |
|
| 168 |
}) |
| 169 |
|
| 170 |
test_that("paths specified with '.' are treated as local", { |
| 171 |
|
| 172 |
renv_tests_scope() |
| 173 |
|
| 174 |
writeLines(con = "DESCRIPTION", c( |
| 175 |
"Type: Package", |
| 176 |
"Package: test", |
| 177 |
"Version: 1.0" |
| 178 |
)) |
| 179 |
|
| 180 |
record <- renv_remotes_resolve(".") |
| 181 |
expect_equal(record$Package, "test") |
| 182 |
expect_equal(record$Version, "1.0") |
| 183 |
|
| 184 |
}) |
| 185 |
|
| 186 |
test_that("packages can be installed from GitLab groups", { |
| 187 |
|
| 188 |
# test parsing of spec |
| 189 |
spec <- "gitlab::renv-group/renv-subgroup/subpackage" |
| 190 |
remote <- renv_remotes_parse(spec) |
| 191 |
|
| 192 |
expected <- list( |
| 193 |
spec = spec, |
| 194 |
package = NULL, |
| 195 |
type = "gitlab", |
| 196 |
host = NULL, |
| 197 |
user = "renv-group", |
| 198 |
repo = "renv-subgroup/subpackage", |
| 199 |
subdir = NULL, |
| 200 |
pull = NULL, |
| 201 |
ref = NULL |
| 202 |
) |
| 203 |
|
| 204 |
expect_equal(remote, expected) |
| 205 |
|
| 206 |
# test installation |
| 207 |
skip_slow() |
| 208 |
renv_tests_scope() |
| 209 |
install(spec) |
| 210 |
expect_true(renv_package_installed("subpackage")) |
| 211 |
|
| 212 |
}) |
| 213 |
|
| 214 |
test_that("remote specs referencing packages in sub-sub-directories are parsed correctly", { |
| 215 |
|
| 216 |
spec <- "github::user/repo/subdir/subsubdir" |
| 217 |
remote <- renv_remotes_parse(spec) |
| 218 |
|
| 219 |
expected <- list( |
| 220 |
spec = spec, |
| 221 |
package = NULL, |
| 222 |
type = "github", |
| 223 |
host = NULL, |
| 224 |
user = "user", |
| 225 |
repo = "repo", |
| 226 |
subdir = "subdir/subsubdir", |
| 227 |
pull = NULL, |
| 228 |
ref = NULL |
| 229 |
) |
| 230 |
|
| 231 |
expect_equal(remote, expected) |
| 232 |
|
| 233 |
}) |
| 234 |
|
| 235 |
test_that("we can parse remotes containing multiple '@'s", { |
| 236 |
|
| 237 |
spec <- "user/repo@ref-has-@-inside" |
| 238 |
remote <- renv_remotes_parse(spec) |
| 239 |
|
| 240 |
expected <- list( |
| 241 |
spec = spec, |
| 242 |
package = NULL, |
| 243 |
type = "github", |
| 244 |
host = NULL, |
| 245 |
user = "user", |
| 246 |
repo = "repo", |
| 247 |
subdir = NULL, |
| 248 |
pull = NULL, |
| 249 |
ref = "ref-has-@-inside" |
| 250 |
) |
| 251 |
|
| 252 |
expect_equal(remote, expected) |
| 253 |
|
| 254 |
}) |