-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added reindexVersion function for the latest gobbler API.
- Loading branch information
Showing
7 changed files
with
113 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#' Reindex a versioned asset | ||
#' | ||
#' Reindex a version of an asset of a project from the registry. | ||
#' This regenerates all of the internal \code{..manifest} and \code{..links} files. | ||
#' | ||
#' @param project String containing the project to remove. | ||
#' @param asset String containing the asset to remove. | ||
#' @param version String containing the version of the asset to remove. | ||
#' @inheritParams createProject | ||
#' | ||
#' @return \code{NULL} is invisibly returned if the version was successfully reindexed. | ||
#' | ||
#' @author Aaron Lun | ||
#' | ||
#' @examples | ||
#' info <- startGobbler() | ||
#' removeProject("test", info$staging, url=info$url) # start with a clean slate. | ||
#' createProject("test", info$staging, url=info$url) | ||
#' | ||
#' # Mocking up a version if it doesn't already exist. | ||
#' src <- allocateUploadDirectory(info$staging) | ||
#' write(file=file.path(src, "foo"), "BAR") | ||
#' uploadDirectory("test", "simple", "v1", src, staging=info$staging, url=info$url) | ||
#' fetchManifest("test", "simple", "v1", registry=info$registry, url=info$url) | ||
#' | ||
#' # Let's add a new file directly to the directory. | ||
#' write(file=file.path(info$registry, "test", "simple", "v1", "whee"), "stuff") | ||
#' | ||
#' # And reindexing the version. | ||
#' reindexVersion("test", "simple", "v1", staging=info$staging, url=info$url) | ||
#' fetchManifest("test", "simple", "v1", registry=info$registry, url=info$url) | ||
#' | ||
#' @export | ||
reindexVersion <- function(project, asset, version, staging, url) { | ||
dump_request(staging, url, "reindex_version", list(project=project, asset=asset, version=version)) | ||
invisible(NULL) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# library(testthat); library(gobbler); source("test-reindexVersion.R") | ||
|
||
info <- startGobbler() | ||
removeProject("test-R-reindex", staging=info$staging, url=info$url) | ||
createProject("test-R-reindex", staging=info$staging, url=info$url) | ||
|
||
test_that("reindexing functions work as expected", { | ||
src <- allocateUploadDirectory(info$staging) | ||
write(file=file.path(src, "foo"), "BAR") | ||
uploadDirectory("test-R-reindex", "simple", "v1", src, staging=info$staging, url=info$url) | ||
|
||
# Let's add a new file directly to the directory. | ||
write(file=file.path(info$registry, "test-R-reindex", "simple", "v1", "whee"), "stuff") | ||
|
||
# This does not show up in the manifest... | ||
man <- fetchManifest("test-R-reindex", "simple", "v1", registry=info$registry, url=info$url) | ||
expect_identical(names(man), "foo") | ||
|
||
# Until we reindex the version. | ||
reindexVersion("test-R-reindex", "simple", "v1", staging=info$staging, url=info$url) | ||
man <- fetchManifest("test-R-reindex", "simple", "v1", registry=info$registry, url=info$url) | ||
expect_identical(names(man), c("foo", "whee")) | ||
}) |