-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa0b67c
commit 9f7aae7
Showing
7 changed files
with
214 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ Imports: | |
jsonlite, | ||
nanonext, | ||
pkgsearch, | ||
utils, | ||
vctrs | ||
Encoding: UTF-8 | ||
Language: en-US | ||
|
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
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,169 @@ | ||
# Temporary files used in the mock test. | ||
manifest <- tempfile() | ||
issues <- tempfile() | ||
|
||
# First update to the manifest. | ||
contents <- data.frame( | ||
package = c( | ||
"package_unmodified", | ||
"version_decremented", | ||
"version_incremented", | ||
"version_unmodified" | ||
), | ||
version_current = rep("1.0.0", 4L), | ||
md5_current = rep("md5_1.0.0", 4L) | ||
) | ||
r.releases.utils::record_versions( | ||
manifest = manifest, | ||
issues = issues, | ||
current = contents | ||
) | ||
written <- jsonlite::read_json(manifest) | ||
expected <- list( | ||
list( | ||
package = "package_unmodified", | ||
version_current = "1.0.0", | ||
md5_current = "md5_1.0.0" | ||
), | ||
list( | ||
package = "version_decremented", | ||
version_current = "1.0.0", | ||
md5_current = "md5_1.0.0" | ||
), | ||
list( | ||
package = "version_incremented", | ||
version_current = "1.0.0", | ||
md5_current = "md5_1.0.0" | ||
), | ||
list( | ||
package = "version_unmodified", | ||
version_current = "1.0.0", | ||
md5_current = "md5_1.0.0" | ||
) | ||
) | ||
stopifnot(identical(written, expected)) | ||
stopifnot(!file.exists(issues)) | ||
|
||
# Update the manifest after no changes to packages or versions. | ||
r.releases.utils::record_versions( | ||
manifest = manifest, | ||
issues = issues, | ||
current = contents | ||
) | ||
written <- jsonlite::read_json(manifest) | ||
expected <- list( | ||
list( | ||
package = "package_unmodified", | ||
version_current = "1.0.0", | ||
md5_current = "md5_1.0.0", | ||
version_highest = "1.0.0", | ||
md5_highest = "md5_1.0.0" | ||
), | ||
list( | ||
package = "version_decremented", | ||
version_current = "1.0.0", | ||
md5_current = "md5_1.0.0", | ||
version_highest = "1.0.0", | ||
md5_highest = "md5_1.0.0" | ||
), | ||
list( | ||
package = "version_incremented", | ||
version_current = "1.0.0", | ||
md5_current = "md5_1.0.0", | ||
version_highest = "1.0.0", | ||
md5_highest = "md5_1.0.0" | ||
), | ||
list( | ||
package = "version_unmodified", | ||
version_current = "1.0.0", | ||
md5_current = "md5_1.0.0", | ||
version_highest = "1.0.0", | ||
md5_highest = "md5_1.0.0" | ||
) | ||
) | ||
stopifnot(identical(written, expected)) | ||
stopifnot(file.exists(issues)) | ||
stopifnot(identical(jsonlite::read_json(issues), list())) | ||
|
||
# Update the packages in all the ways indicated above. | ||
index <- contents$package == "version_decremented" | ||
contents$version_current[index] <- "0.0.1" | ||
contents$md5_current[index] <- "md5_0.0.1" | ||
index <- contents$package == "version_incremented" | ||
contents$version_current[index] <- "2.0.0" | ||
contents$md5_current[index] <- "md5_2.0.0" | ||
index <- contents$package == "version_unmodified" | ||
contents$version_current[index] <- "1.0.0" | ||
contents$md5_current[index] <- "md5_1.0.0-modified" | ||
r.releases.utils::record_versions( | ||
manifest = manifest, | ||
issues = issues, | ||
current = contents | ||
) | ||
written <- jsonlite::read_json(manifest) | ||
expected <- list( | ||
list( | ||
package = "package_unmodified", | ||
version_current = "1.0.0", | ||
md5_current = "md5_1.0.0", | ||
version_highest = "1.0.0", | ||
md5_highest = "md5_1.0.0" | ||
), | ||
list( | ||
package = "version_decremented", | ||
version_current = "0.0.1", | ||
md5_current = "md5_0.0.1", | ||
version_highest = "1.0.0", | ||
md5_highest = "md5_1.0.0" | ||
), | ||
list( | ||
package = "version_incremented", | ||
version_current = "2.0.0", | ||
md5_current = "md5_2.0.0", | ||
version_highest = "2.0.0", | ||
md5_highest = "md5_2.0.0" | ||
), | ||
list( | ||
package = "version_unmodified", | ||
version_current = "1.0.0", | ||
md5_current = "md5_1.0.0-modified", | ||
version_highest = "1.0.0", | ||
md5_highest = "md5_1.0.0" | ||
) | ||
) | ||
stopifnot(identical(written, expected)) | ||
stopifnot(file.exists(issues)) | ||
written_issues <- jsonlite::read_json(issues) | ||
expected_issues <- list( | ||
list( | ||
package = "version_decremented", | ||
version_current = "0.0.1", | ||
md5_current = "md5_0.0.1", | ||
version_highest = "1.0.0", | ||
md5_highest = "md5_1.0.0" | ||
), | ||
list( | ||
package = "version_unmodified", | ||
version_current = "1.0.0", | ||
md5_current = "md5_1.0.0-modified", | ||
version_highest = "1.0.0", | ||
md5_highest = "md5_1.0.0" | ||
) | ||
) | ||
stopifnot(identical(written_issues, expected_issues)) | ||
|
||
# Remove temporary files | ||
unlink(c(manifest, issues)) | ||
|
||
# The manifest can be created and updated from the actual repo. | ||
manifest <- tempfile() | ||
issues <- tempfile() | ||
r.releases.utils::record_versions(manifest = manifest, issues = issues) | ||
stopifnot(file.exists(manifest)) | ||
r.releases.utils::record_versions(manifest = manifest, issues = issues) | ||
contents <- jsonlite::read_json(manifest) | ||
stopifnot(is.character(contents[[1L]]$package)) | ||
stopifnot(length(contents[[1L]]$package) == 1L) | ||
stopifnot(file.exists(manifest)) | ||
stopifnot(file.exists(issues)) | ||
unlink(c(manifest, issues)) |