Skip to content

Commit

Permalink
Fix how multiple pin name matches from a Connect board are filtered (#…
Browse files Browse the repository at this point in the history
…835)

* Fix bug filtering multiple matches from Connect

* add mocked test

---------

Co-authored-by: Julia Silge <[email protected]>
  • Loading branch information
toph-allen and juliasilge authored Aug 2, 2024
1 parent 21e5e4e commit 2edcccb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/board_connect.R
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ rsc_content_find <- function(board, name, version = NULL, warn = TRUE) {
class = "pins_pin_missing"
)
}
selected <- json[[name$owner %in% owner_names]]
selected <- json[[which(name$owner == owner_names)]]
}

content <- list(
Expand Down
25 changes: 25 additions & 0 deletions tests/testthat/test-board_connect-mocks.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
test_that("rsc_content_find correctly filters multiple results by owner name", {
local_mocked_bindings(
rsc_GET = function(board, path, query) {
list(
list(
name = "penguins",
owner_guid = "taylor_guid",
guid = "bad_content_guid",
content_url = "wrong.url"
),
list(
name = "penguins",
owner_guid = "toph_guid",
guid = "good_content_guid",
content_url = "correct.url"
)
)
},
rsc_user_name = function(board, guid) {
c(taylor_guid = "taylor", toph_guid = "toph")[[guid]]
}
)
found <- rsc_content_find("a board", "toph/penguins")
expect_identical(found, list(guid = "good_content_guid", url = "correct.url"))
})

0 comments on commit 2edcccb

Please sign in to comment.