forked from r-lib/usethis
-
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.
Allow appending urls in
use_github_links()
(r-lib#1834)
* Allow appending urls in use_github_links() * account for no existing URL field * Add NEWS bullet * Use desc$set_list in use_description_field * let use_description_field() construct url list also let it handle overwrite behaviour * Update tests, lean more on desc * Use github_url_from_git_remotes() and mock that * Consolidate tests * Update code comment in use_description_field * Move skips to top of tests
- Loading branch information
Showing
4 changed files
with
54 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,8 @@ | ||
# use_github_links() aborts or appends URLs when it should | ||
|
||
Code | ||
use_github_links(overwrite = FALSE) | ||
Condition | ||
Error: | ||
! URL has a different value in DESCRIPTION. Use `overwrite = TRUE` to overwrite. | ||
|
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,42 @@ | ||
test_that("use_github_links populates empty URL field", { | ||
skip_if_no_git_user() | ||
local_interactive(FALSE) | ||
create_local_package() | ||
use_git() | ||
|
||
local_mocked_bindings( | ||
github_url_from_git_remotes = function() "https://github.com/OWNER/REPO" | ||
) | ||
|
||
# when no URL field | ||
use_github_links() | ||
expect_equal(proj_desc()$get_urls(), "https://github.com/OWNER/REPO") | ||
expect_equal( | ||
proj_desc()$get_field("BugReports"), | ||
"https://github.com/OWNER/REPO/issues" | ||
) | ||
}) | ||
|
||
test_that("use_github_links() aborts or appends URLs when it should", { | ||
skip_if_no_git_user() | ||
local_interactive(FALSE) | ||
create_local_package() | ||
use_git() | ||
|
||
local_mocked_bindings( | ||
github_url_from_git_remotes = function() "https://github.com/OWNER/REPO" | ||
) | ||
|
||
d <- proj_desc() | ||
d$set_urls(c("https://existing.url", "https://existing.url1")) | ||
d$write() | ||
|
||
expect_snapshot(use_github_links(overwrite = FALSE), error = TRUE) | ||
|
||
use_github_links(overwrite = TRUE) | ||
expect_equal( | ||
proj_desc()$get_urls(), | ||
c("https://existing.url", "https://existing.url1", | ||
"https://github.com/OWNER/REPO") | ||
) | ||
}) |