@@ -103,3 +103,50 @@ test_that("annotatePkgDesc annotates a package description", {
103103 expect_equal(result $ InstallAgent , paste(' packrat' , packageVersion(' packrat' )))
104104 expect_equal(result $ InstallSource , " CRAN" )
105105})
106+
107+ test_that(" appendRemoteInfoToDescription uses RemoteSubdir" , {
108+ parent_dir <- withr :: local_tempdir()
109+ dest_dir <- withr :: local_tempdir()
110+ # create package dir with subdirectory
111+ src_dir <- file.path(parent_dir , " bread" , " toast" )
112+ dir.create(src_dir , recursive = TRUE )
113+
114+ writeLines(
115+ readLines(test_path(" packages/toast/DESCRIPTION" )),
116+ file.path(src_dir , " DESCRIPTION" )
117+ )
118+
119+ parent_tarball <- paste0(parent_dir , " .tar.gz" )
120+ dest_tarball <- paste0(dest_dir , " .tar.gz" )
121+
122+ in_dir(
123+ parent_dir ,
124+ tar(
125+ tarfile = parent_tarball ,
126+ files = " bread" ,
127+ compression = " gzip" ,
128+ tar = tar_binary()
129+ )
130+ )
131+
132+ remote_info <- data.frame (
133+ RemoteType = " github" ,
134+ RemoteHost = " github.com" ,
135+ RemoteRepo = " bread" ,
136+ RemoteUsername = " breakfaster" ,
137+ RemoteRef = " HEAD" ,
138+ RemoteSha = " abc123" ,
139+ RemoteSubdir = " toast" ,
140+ stringsAsFactors = FALSE
141+ )
142+
143+ appendRemoteInfoToDescription(
144+ src = parent_tarball ,
145+ dest = dest_tarball ,
146+ remote_info = remote_info
147+ )
148+
149+ untar(dest_tarball , exdir = dest_dir , tar = tar_binary())
150+ desc <- readLines(file.path(dest_dir , " toast" , " DESCRIPTION" ))
151+ expect_true(" RemoteSubdir: toast" %in% desc )
152+ })
0 commit comments