1context("install_bioc.R")
2
3test_that("bioc repo paths are parsed correctly", {
4  expect_equal(parse_bioc_repo("devtools"), list(repo="devtools"))
5  expect_equal(parse_bioc_repo("devtools#abc123"), list(repo="devtools", commit="abc123"))
6  expect_equal(parse_bioc_repo("user:pass@devtools"), list(username = "user", password = "pass", repo="devtools"))
7  expect_equal(parse_bioc_repo("devel/devtools"), list(release = "devel", repo="devtools"))
8  expect_equal(parse_bioc_repo("3.1/devtools"), list(release = "3.1", repo="devtools"))
9  expect_equal(parse_bioc_repo("release/devtools"), list(release = "release", repo="devtools"))
10  expect_equal(parse_bioc_repo("user:pass@devtools#abc123"), list(username = "user", password = "pass", repo="devtools", commit = "abc123"))
11  expect_error(parse_bioc_repo("user:pass@3.1/devtools#abc123"), "release and commit should not both be specified")
12  expect_error(parse_bioc_repo("user@devtools"), "Invalid bioc repo")
13  expect_error(parse_bioc_repo("user:@devtools"), "Invalid bioc repo")
14  expect_error(parse_bioc_repo("@devtools"), "Invalid bioc repo")
15  expect_error(parse_bioc_repo("devtools/"), "Invalid bioc repo")
16  expect_error(parse_bioc_repo("junk/devtools"), "Invalid bioc repo")
17})
18
19test_that("install_bioc with git2r", {
20
21  skip_without_package("git2r")
22  skip_on_cran()
23  skip_if_offline()
24
25  lib <- tempfile()
26  on.exit(unlink(lib, recursive = TRUE), add = TRUE)
27  dir.create(lib)
28
29  mirror <- getOption("BioC_git", "https://git.bioconductor.org/packages")
30
31  # This package has no dependencies or compiled code and is old
32  install_bioc("MeasurementError.cor", mirror = mirror, git = "git2r", lib = lib, quiet = TRUE)
33
34  expect_silent(packageDescription("MeasurementError.cor", lib.loc = lib))
35  expect_equal(packageDescription("MeasurementError.cor", lib.loc = lib)$RemoteType, "bioc_git2r")
36
37  remote <- package2remote("MeasurementError.cor", lib = lib)
38  expect_s3_class(remote, "remote")
39  expect_s3_class(remote, "bioc_git2r_remote")
40  expect_equal(format(remote), "Bioc")
41  expect_equal(remote$mirror, mirror)
42  expect_equal(remote$repo, "MeasurementError.cor")
43  expect_equal(remote$release, "release")
44  expect_true(!is.na(remote$sha) && nzchar(remote$sha))
45  expect_true(!is.na(remote$branch) && nzchar(remote$branch))
46})
47
48test_that("install_bioc with xgit", {
49
50  skip_without_program("git")
51  skip_on_cran()
52  skip_if_offline()
53
54  lib <- tempfile()
55  on.exit(unlink(lib, recursive = TRUE), add = TRUE)
56  dir.create(lib)
57
58  mirror <- getOption("BioC_git", "https://git.bioconductor.org/packages")
59
60
61  # This package has no dependencies or compiled code and is old
62  install_bioc("MeasurementError.cor", mirror = mirror, git = "external", lib = lib, quiet = TRUE)
63
64  expect_silent(packageDescription("MeasurementError.cor", lib.loc = lib))
65  expect_equal(packageDescription("MeasurementError.cor", lib.loc = lib)$RemoteType, "bioc_xgit")
66
67  remote <- package2remote("MeasurementError.cor", lib = lib)
68  expect_s3_class(remote, "remote")
69  expect_s3_class(remote, "bioc_xgit_remote")
70  expect_equal(format(remote), "Bioc")
71  expect_equal(remote$mirror, mirror)
72  expect_equal(remote$repo, "MeasurementError.cor")
73  expect_equal(remote$release, "release")
74  expect_true(!is.na(remote$sha) && nzchar(remote$sha))
75  expect_true(!is.na(remote$branch) && nzchar(remote$branch))
76})
77