From 4fe626521a83f2a54a4ae510965554891ecf69b9 Mon Sep 17 00:00:00 2001 From: Toph Allen Date: Thu, 2 Oct 2025 19:01:34 -0400 Subject: [PATCH 1/9] add pagination to search_content() --- R/content.R | 43 ++++--- man/search_content.Rd | 17 +-- .../__api__/v1/search/content-0f26be.json | 1 + .../__api__/v1/search/content-d37a6d.json | 118 ++++++++++++++++++ .../__api__/v1/search/content-eaf9f2.json | 62 +++++++++ tests/testthat/test-content.R | 19 ++- 6 files changed, 222 insertions(+), 38 deletions(-) create mode 100644 tests/testthat/2025.09.0/__api__/v1/search/content-d37a6d.json create mode 100644 tests/testthat/2025.09.0/__api__/v1/search/content-eaf9f2.json diff --git a/R/content.R b/R/content.R index b7c04cab..132174a3 100644 --- a/R/content.R +++ b/R/content.R @@ -1441,12 +1441,6 @@ get_content_packages <- function(content) { #' @param q The search query, using the syntax described in the Connect #' documentation on [content search #' terms](https://docs.posit.co/connect/user/viewing-content/#searching-content) -#' @param page_number Integer. The page to return relative to the given `page_size`. -#' Must be greater than 0. -#' @param page_size Integer. The number of items to include in each page. This -#' parameter is "best effort" since there may not be enough results to honor the -#' request. If `page_size` is less than 1 or greater than 500, an error will be -#' returned. #' @param include Comma-separated character string of values indicating additional #' details to include in the response. Values can be `owner` and `vanity_url`; #' both are included by default. @@ -1587,21 +1581,38 @@ get_content_packages <- function(content) { search_content <- function( client, q = NULL, - page_number = 1, - page_size = 500, include = "owner,vanity_url", ... ) { error_if_less_than(client$version, "2024.04.0") - path <- v1_url("search", "content") + inner_search <- function( + client, + q, + page_number, + page_size, + include + ) { + path <- v1_url("search", "content") - query <- list( - q = q, - page_number = page_number, - page_size = page_size, - include = include - ) + query <- list( + q = q, + page_number = page_number, + page_size = page_size, + include = include + ) - client$GET(path, query = query) + client$GET(path, query = query) + } + + page_offset( + client, + req = inner_search( + client, + q = q, + page_number = 1, + page_size = 500, + include = include + ) + ) } diff --git a/man/search_content.Rd b/man/search_content.Rd index 5fa2b507..f15e830f 100644 --- a/man/search_content.Rd +++ b/man/search_content.Rd @@ -4,14 +4,7 @@ \alias{search_content} \title{Search for content on the Connect server} \usage{ -search_content( - client, - q = NULL, - page_number = 1, - page_size = 500, - include = "owner,vanity_url", - ... -) +search_content(client, q = NULL, include = "owner,vanity_url", ...) } \arguments{ \item{client}{A Connect object} @@ -19,14 +12,6 @@ search_content( \item{q}{The search query, using the syntax described in the Connect documentation on \href{https://docs.posit.co/connect/user/viewing-content/#searching-content}{content search terms}} -\item{page_number}{Integer. The page to return relative to the given \code{page_size}. -Must be greater than 0.} - -\item{page_size}{Integer. The number of items to include in each page. This -parameter is "best effort" since there may not be enough results to honor the -request. If \code{page_size} is less than 1 or greater than 500, an error will be -returned.} - \item{include}{Comma-separated character string of values indicating additional details to include in the response. Values can be \code{owner} and \code{vanity_url}; both are included by default.} diff --git a/tests/testthat/2025.09.0/__api__/v1/search/content-0f26be.json b/tests/testthat/2025.09.0/__api__/v1/search/content-0f26be.json index 5bdf3d30..96ae144a 100644 --- a/tests/testthat/2025.09.0/__api__/v1/search/content-0f26be.json +++ b/tests/testthat/2025.09.0/__api__/v1/search/content-0f26be.json @@ -1,5 +1,6 @@ { "total": 2, + "current_page": 1, "results": [ { "guid": "c9f68287", diff --git a/tests/testthat/2025.09.0/__api__/v1/search/content-d37a6d.json b/tests/testthat/2025.09.0/__api__/v1/search/content-d37a6d.json new file mode 100644 index 00000000..3c256db5 --- /dev/null +++ b/tests/testthat/2025.09.0/__api__/v1/search/content-d37a6d.json @@ -0,0 +1,118 @@ +{ + "total": 3, + "current_page": 1, + "results": [ + { + "guid": "c9f68287", + "name": "blobfish-dashboard", + "title": "blobfish dashboard", + "description": "", + "access_type": "all", + "locked": false, + "locked_message": "", + "connection_timeout": null, + "read_timeout": null, + "init_timeout": null, + "idle_timeout": null, + "max_processes": null, + "min_processes": null, + "max_conns_per_process": null, + "load_factor": null, + "memory_request": null, + "memory_limit": null, + "cpu_request": null, + "cpu_limit": null, + "amd_gpu_limit": null, + "nvidia_gpu_limit": null, + "service_account_name": null, + "default_image_name": null, + "default_environment_guid": null, + "created_time": "2024-08-29T17:52:30Z", + "last_deployed_time": "2025-09-25T17:26:05Z", + "bundle_id": "306864", + "app_mode": "python-shiny", + "content_category": "", + "parameterized": false, + "environment_guid": null, + "cluster_name": "Local", + "image_name": null, + "r_version": null, + "py_version": "3.10.17", + "quarto_version": null, + "r_environment_management": null, + "default_r_environment_management": null, + "py_environment_management": true, + "default_py_environment_management": null, + "run_as": null, + "run_as_current_user": false, + "owner_guid": "c2250bb4", + "content_url": "https://connect.example/content/c9f68287/", + "dashboard_url": "https://connect.example/connect/#/apps/c9f68287", + "app_role": "none", + "id": "57138", + "owner": { + "guid": "c2250bb4", + "username": "toph_allen", + "first_name": "Toph", + "last_name": "Allen" + }, + "public_content_status": null + }, + { + "guid": "53032a0e", + "name": "blobfish-api", + "title": "blobfish api", + "description": "", + "access_type": "all", + "locked": false, + "locked_message": "", + "connection_timeout": null, + "read_timeout": null, + "init_timeout": null, + "idle_timeout": null, + "max_processes": null, + "min_processes": null, + "max_conns_per_process": null, + "load_factor": null, + "memory_request": null, + "memory_limit": null, + "cpu_request": null, + "cpu_limit": null, + "amd_gpu_limit": null, + "nvidia_gpu_limit": null, + "service_account_name": null, + "default_image_name": null, + "default_environment_guid": null, + "created_time": "2024-08-29T17:49:34Z", + "last_deployed_time": "2025-09-25T17:23:21Z", + "bundle_id": "306844", + "app_mode": "fastapi", + "content_category": "", + "parameterized": false, + "environment_guid": null, + "cluster_name": "Local", + "image_name": null, + "r_version": null, + "py_version": "3.10.17", + "quarto_version": null, + "r_environment_management": null, + "default_r_environment_management": null, + "py_environment_management": true, + "default_py_environment_management": null, + "run_as": null, + "run_as_current_user": false, + "owner_guid": "c2250bb4", + "content_url": "https://connect.example/content/53032a0e/", + "dashboard_url": "https://connect.example/connect/#/apps/53032a0e", + "app_role": "none", + "id": "57137", + "owner": { + "guid": "c2250bb4", + "username": "toph_allen", + "first_name": "Toph", + "last_name": "Allen" + }, + "public_content_status": null + } + ] +} diff --git a/tests/testthat/2025.09.0/__api__/v1/search/content-eaf9f2.json b/tests/testthat/2025.09.0/__api__/v1/search/content-eaf9f2.json new file mode 100644 index 00000000..346f89d4 --- /dev/null +++ b/tests/testthat/2025.09.0/__api__/v1/search/content-eaf9f2.json @@ -0,0 +1,62 @@ +{ + "total": 3, + "current_page": 2, + "results": [ + { + "guid": "abc12345", + "name": "blobfish-report", + "title": "blobfish report", + "description": "", + "access_type": "all", + "locked": false, + "locked_message": "", + "connection_timeout": null, + "read_timeout": null, + "init_timeout": null, + "idle_timeout": null, + "max_processes": null, + "min_processes": null, + "max_conns_per_process": null, + "load_factor": null, + "memory_request": null, + "memory_limit": null, + "cpu_request": null, + "cpu_limit": null, + "amd_gpu_limit": null, + "nvidia_gpu_limit": null, + "service_account_name": null, + "default_image_name": null, + "default_environment_guid": null, + "created_time": "2024-08-29T17:52:30Z", + "last_deployed_time": "2025-09-25T17:26:05Z", + "bundle_id": "306864", + "app_mode": "python-shiny", + "content_category": "", + "parameterized": false, + "environment_guid": null, + "cluster_name": "Local", + "image_name": null, + "r_version": null, + "py_version": "3.10.17", + "quarto_version": null, + "r_environment_management": null, + "default_r_environment_management": null, + "py_environment_management": true, + "default_py_environment_management": null, + "run_as": null, + "run_as_current_user": false, + "owner_guid": "c2250bb4", + "content_url": "https://connect.example/content/abc12345/", + "dashboard_url": "https://connect.example/connect/#/apps/abc12345", + "app_role": "none", + "id": "57138", + "owner": { + "guid": "c2250bb4", + "username": "toph_allen", + "first_name": "Toph", + "last_name": "Allen" + }, + "public_content_status": null + } + ] +} diff --git a/tests/testthat/test-content.R b/tests/testthat/test-content.R index 4047953e..960a8af7 100644 --- a/tests/testthat/test-content.R +++ b/tests/testthat/test-content.R @@ -478,26 +478,33 @@ with_mock_dir("2025.09.0", { test_that("content search returns the expected list of content", { res <- search_content(client, q = "sea bream") expect_equal( - purrr::map_chr(res$results, "owner_guid"), + purrr::map_chr(res, "owner_guid"), c("c2250bb4", "c2250bb4") ) expect_equal( - purrr::map_chr(res$results, "title"), + purrr::map_chr(res, "title"), c("sea bream report", "sea bream dashboard") ) }) + test_that("content search fetches multiple pages correctly", { + res <- search_content(client, q = "blobfish") + expect_equal(length(res), 3) + expect_equal( + purrr::map_chr(res, "title"), + c("blobfish dashboard", "blobfish api", "blobfish report") + ) + }) + test_that("content search passes all parameters through correctly", { without_internet( expect_GET( search_content( client, q = "bream", - include = "owner", - page_number = 2, - page_size = 5 + include = "owner" ), - "https://connect.example/__api__/v1/search/content?q=bream&page_number=2&page_size=5&include=owner" + "https://connect.example/__api__/v1/search/content?q=bream&page_number=1&page_size=500&include=owner" ) ) }) From 139a64e65cc5e9ed5572f1cfceb8a3d28eea8943 Mon Sep 17 00:00:00 2001 From: Toph Allen Date: Thu, 2 Oct 2025 19:05:57 -0400 Subject: [PATCH 2/9] update NEWS --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 0624c691..e06fb0dc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,6 +10,8 @@ server: `create_integration()`, `update_integration()` and `delete_integration()`. (#434) - Support content search API with the `search_content()` function. (#272) +- New `search_content()` function which lets you search and filter content items + on the Connect server. (#272, #447) # connectapi 0.8.0 From e321681ac25b77f89d21c4923761986a67a349b8 Mon Sep 17 00:00:00 2001 From: Toph Allen Date: Fri, 3 Oct 2025 10:39:36 -0400 Subject: [PATCH 3/9] =?UTF-8?q?pass=20page=5Fnumber=20and=20page=5Fsize=20?= =?UTF-8?q?down=20via=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- R/content.R | 17 +++++++++++------ man/search_content.Rd | 5 ++++- tests/testthat/test-content.R | 4 +++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/R/content.R b/R/content.R index 132174a3..dbcf817f 100644 --- a/R/content.R +++ b/R/content.R @@ -1444,7 +1444,10 @@ get_content_packages <- function(content) { #' @param include Comma-separated character string of values indicating additional #' details to include in the response. Values can be `owner` and `vanity_url`; #' both are included by default. -#' @param ... Extra arguments. Currently not used. +#' @param ... Extra arguments. Passing in `page_number` and `page_size` will +#' affect the internal pagination for Connect's content search API. Setting +#' `page_number` will change the page at which pagination *starts*, and +#' `page_size` will control the size of pages (max 500). #' #' @return #' A list containing sub-fields: @@ -1589,8 +1592,8 @@ search_content <- function( inner_search <- function( client, q, - page_number, - page_size, + page_number = 1, + page_size = 500, include ) { path <- v1_url("search", "content") @@ -1610,9 +1613,11 @@ search_content <- function( req = inner_search( client, q = q, - page_number = 1, - page_size = 500, - include = include + include = include, + # page_size and page_number can be passed in via `...`. Since this call is + # still passed to page_offset, page_number affects the *starting* page, + # but pagination still continues. + ... ) ) } diff --git a/man/search_content.Rd b/man/search_content.Rd index f15e830f..6f3881b2 100644 --- a/man/search_content.Rd +++ b/man/search_content.Rd @@ -16,7 +16,10 @@ documentation on \href{https://docs.posit.co/connect/user/viewing-content/#searc details to include in the response. Values can be \code{owner} and \code{vanity_url}; both are included by default.} -\item{...}{Extra arguments. Currently not used.} +\item{...}{Extra arguments. Passing in \code{page_number} and \code{page_size} will +affect the internal pagination for Connect's content search API. Setting +\code{page_number} will change the page at which pagination \emph{starts}, and +\code{page_size} will control the size of pages (max 500).} } \value{ A list containing sub-fields: diff --git a/tests/testthat/test-content.R b/tests/testthat/test-content.R index 960a8af7..9a5454f4 100644 --- a/tests/testthat/test-content.R +++ b/tests/testthat/test-content.R @@ -502,9 +502,11 @@ with_mock_dir("2025.09.0", { search_content( client, q = "bream", + page_number = 2, + page_size = 20, include = "owner" ), - "https://connect.example/__api__/v1/search/content?q=bream&page_number=1&page_size=500&include=owner" + "https://connect.example/__api__/v1/search/content?q=bream&page_number=2&page_size=20&include=owner" ) ) }) From 2da67d19513ddceeecda87504a6a4cf3c3e1095f Mon Sep 17 00:00:00 2001 From: Toph Allen Date: Fri, 3 Oct 2025 11:49:44 -0400 Subject: [PATCH 4/9] Update content.R Co-authored-by: Jonathan Keane --- R/content.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/content.R b/R/content.R index dbcf817f..3f1b0a10 100644 --- a/R/content.R +++ b/R/content.R @@ -1589,7 +1589,7 @@ search_content <- function( ) { error_if_less_than(client$version, "2024.04.0") - inner_search <- function( + .search_content <- function( client, q, page_number = 1, From 619d39589e584b608bc7775a44eaefdf80f263f3 Mon Sep 17 00:00:00 2001 From: Toph Allen Date: Fri, 3 Oct 2025 11:54:17 -0400 Subject: [PATCH 5/9] adopt suggestion --- R/content.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/content.R b/R/content.R index 3f1b0a10..2174e56e 100644 --- a/R/content.R +++ b/R/content.R @@ -1610,7 +1610,7 @@ search_content <- function( page_offset( client, - req = inner_search( + req = .search_content( client, q = q, include = include, From d94a39b1b16a123f64502eff4f4263281eb4b20f Mon Sep 17 00:00:00 2001 From: Toph Allen Date: Fri, 3 Oct 2025 12:29:09 -0400 Subject: [PATCH 6/9] Update tests/testthat/2025.09.0/__api__/v1/search/content-d37a6d.json Co-authored-by: Jonathan Keane --- .../__api__/v1/search/content-d37a6d.json | 56 +------------------ 1 file changed, 2 insertions(+), 54 deletions(-) diff --git a/tests/testthat/2025.09.0/__api__/v1/search/content-d37a6d.json b/tests/testthat/2025.09.0/__api__/v1/search/content-d37a6d.json index 3c256db5..925609c8 100644 --- a/tests/testthat/2025.09.0/__api__/v1/search/content-d37a6d.json +++ b/tests/testthat/2025.09.0/__api__/v1/search/content-d37a6d.json @@ -10,40 +10,15 @@ "access_type": "all", "locked": false, "locked_message": "", - "connection_timeout": null, - "read_timeout": null, - "init_timeout": null, - "idle_timeout": null, - "max_processes": null, - "min_processes": null, - "max_conns_per_process": null, - "load_factor": null, - "memory_request": null, - "memory_limit": null, - "cpu_request": null, - "cpu_limit": null, - "amd_gpu_limit": null, - "nvidia_gpu_limit": null, - "service_account_name": null, - "default_image_name": null, - "default_environment_guid": null, "created_time": "2024-08-29T17:52:30Z", "last_deployed_time": "2025-09-25T17:26:05Z", "bundle_id": "306864", "app_mode": "python-shiny", "content_category": "", "parameterized": false, - "environment_guid": null, "cluster_name": "Local", - "image_name": null, - "r_version": null, "py_version": "3.10.17", - "quarto_version": null, - "r_environment_management": null, - "default_r_environment_management": null, "py_environment_management": true, - "default_py_environment_management": null, - "run_as": null, "run_as_current_user": false, "owner_guid": "c2250bb4", "content_url": "https://connect.example/content/c9f68287/", @@ -55,8 +30,7 @@ "username": "toph_allen", "first_name": "Toph", "last_name": "Allen" - }, - "public_content_status": null + } }, { "guid": "53032a0e", @@ -66,40 +40,15 @@ "access_type": "all", "locked": false, "locked_message": "", - "connection_timeout": null, - "read_timeout": null, - "init_timeout": null, - "idle_timeout": null, - "max_processes": null, - "min_processes": null, - "max_conns_per_process": null, - "load_factor": null, - "memory_request": null, - "memory_limit": null, - "cpu_request": null, - "cpu_limit": null, - "amd_gpu_limit": null, - "nvidia_gpu_limit": null, - "service_account_name": null, - "default_image_name": null, - "default_environment_guid": null, "created_time": "2024-08-29T17:49:34Z", "last_deployed_time": "2025-09-25T17:23:21Z", "bundle_id": "306844", "app_mode": "fastapi", "content_category": "", "parameterized": false, - "environment_guid": null, "cluster_name": "Local", - "image_name": null, - "r_version": null, "py_version": "3.10.17", - "quarto_version": null, - "r_environment_management": null, - "default_r_environment_management": null, "py_environment_management": true, - "default_py_environment_management": null, - "run_as": null, "run_as_current_user": false, "owner_guid": "c2250bb4", "content_url": "https://connect.example/content/53032a0e/", @@ -111,8 +60,7 @@ "username": "toph_allen", "first_name": "Toph", "last_name": "Allen" - }, - "public_content_status": null + } } ] } From 038d481d08fe889deccc6beae5d79e3332256712 Mon Sep 17 00:00:00 2001 From: Toph Allen Date: Fri, 3 Oct 2025 12:42:54 -0400 Subject: [PATCH 7/9] simplify test fixtures --- .../__api__/v1/search/content-0f26be.json | 107 +----------------- .../__api__/v1/search/content-d37a6d.json | 55 +-------- .../__api__/v1/search/content-eaf9f2.json | 54 +-------- tests/testthat/test-content.R | 4 +- 4 files changed, 10 insertions(+), 210 deletions(-) diff --git a/tests/testthat/2025.09.0/__api__/v1/search/content-0f26be.json b/tests/testthat/2025.09.0/__api__/v1/search/content-0f26be.json index 96ae144a..7dfbeda0 100644 --- a/tests/testthat/2025.09.0/__api__/v1/search/content-0f26be.json +++ b/tests/testthat/2025.09.0/__api__/v1/search/content-0f26be.json @@ -1,3 +1,4 @@ +// Used in test-content.R { "total": 2, "current_page": 1, @@ -5,114 +6,12 @@ { "guid": "c9f68287", "name": "sea-bream-report", - "title": "sea bream report", - "description": "", - "access_type": "all", - "locked": false, - "locked_message": "", - "connection_timeout": null, - "read_timeout": null, - "init_timeout": null, - "idle_timeout": null, - "max_processes": null, - "min_processes": null, - "max_conns_per_process": null, - "load_factor": null, - "memory_request": null, - "memory_limit": null, - "cpu_request": null, - "cpu_limit": null, - "amd_gpu_limit": null, - "nvidia_gpu_limit": null, - "service_account_name": null, - "default_image_name": null, - "default_environment_guid": null, - "created_time": "2024-08-29T17:52:30Z", - "last_deployed_time": "2025-09-25T17:26:05Z", - "bundle_id": "306864", - "app_mode": "python-shiny", - "content_category": "", - "parameterized": false, - "environment_guid": null, - "cluster_name": "Local", - "image_name": null, - "r_version": null, - "py_version": "3.10.17", - "quarto_version": null, - "r_environment_management": null, - "default_r_environment_management": null, - "py_environment_management": true, - "default_py_environment_management": null, - "run_as": null, - "run_as_current_user": false, - "owner_guid": "c2250bb4", - "content_url": "https://connect.example/content/c9f68287/", - "dashboard_url": "https://connect.example/connect/#/apps/c9f68287", - "app_role": "none", - "id": "57138", - "owner": { - "guid": "c2250bb4", - "username": "toph_allen", - "first_name": "Toph", - "last_name": "Allen" - }, - "public_content_status": null + "title": "sea bream report" }, { "guid": "53032a0e", "name": "sea-bream-dashboard", - "title": "sea bream dashboard", - "description": "", - "access_type": "all", - "locked": false, - "locked_message": "", - "connection_timeout": null, - "read_timeout": null, - "init_timeout": null, - "idle_timeout": null, - "max_processes": null, - "min_processes": null, - "max_conns_per_process": null, - "load_factor": null, - "memory_request": null, - "memory_limit": null, - "cpu_request": null, - "cpu_limit": null, - "amd_gpu_limit": null, - "nvidia_gpu_limit": null, - "service_account_name": null, - "default_image_name": null, - "default_environment_guid": null, - "created_time": "2024-08-29T17:49:34Z", - "last_deployed_time": "2025-09-25T17:23:21Z", - "bundle_id": "306844", - "app_mode": "python-shiny", - "content_category": "", - "parameterized": false, - "environment_guid": null, - "cluster_name": "Local", - "image_name": null, - "r_version": null, - "py_version": "3.10.17", - "quarto_version": null, - "r_environment_management": null, - "default_r_environment_management": null, - "py_environment_management": true, - "default_py_environment_management": null, - "run_as": null, - "run_as_current_user": false, - "owner_guid": "c2250bb4", - "content_url": "https://connect.example/content/53032a0e/", - "dashboard_url": "https://connect.example/connect/#/apps/53032a0e", - "app_role": "none", - "id": "57137", - "owner": { - "guid": "c2250bb4", - "username": "toph_allen", - "first_name": "Toph", - "last_name": "Allen" - }, - "public_content_status": null + "title": "sea bream dashboard" } ] } diff --git a/tests/testthat/2025.09.0/__api__/v1/search/content-d37a6d.json b/tests/testthat/2025.09.0/__api__/v1/search/content-d37a6d.json index 925609c8..f51e9959 100644 --- a/tests/testthat/2025.09.0/__api__/v1/search/content-d37a6d.json +++ b/tests/testthat/2025.09.0/__api__/v1/search/content-d37a6d.json @@ -1,3 +1,4 @@ +// Used in test-content.R { "total": 3, "current_page": 1, @@ -5,62 +6,12 @@ { "guid": "c9f68287", "name": "blobfish-dashboard", - "title": "blobfish dashboard", - "description": "", - "access_type": "all", - "locked": false, - "locked_message": "", - "created_time": "2024-08-29T17:52:30Z", - "last_deployed_time": "2025-09-25T17:26:05Z", - "bundle_id": "306864", - "app_mode": "python-shiny", - "content_category": "", - "parameterized": false, - "cluster_name": "Local", - "py_version": "3.10.17", - "py_environment_management": true, - "run_as_current_user": false, - "owner_guid": "c2250bb4", - "content_url": "https://connect.example/content/c9f68287/", - "dashboard_url": "https://connect.example/connect/#/apps/c9f68287", - "app_role": "none", - "id": "57138", - "owner": { - "guid": "c2250bb4", - "username": "toph_allen", - "first_name": "Toph", - "last_name": "Allen" - } + "title": "blobfish dashboard" }, { "guid": "53032a0e", "name": "blobfish-api", - "title": "blobfish api", - "description": "", - "access_type": "all", - "locked": false, - "locked_message": "", - "created_time": "2024-08-29T17:49:34Z", - "last_deployed_time": "2025-09-25T17:23:21Z", - "bundle_id": "306844", - "app_mode": "fastapi", - "content_category": "", - "parameterized": false, - "cluster_name": "Local", - "py_version": "3.10.17", - "py_environment_management": true, - "run_as_current_user": false, - "owner_guid": "c2250bb4", - "content_url": "https://connect.example/content/53032a0e/", - "dashboard_url": "https://connect.example/connect/#/apps/53032a0e", - "app_role": "none", - "id": "57137", - "owner": { - "guid": "c2250bb4", - "username": "toph_allen", - "first_name": "Toph", - "last_name": "Allen" - } + "title": "blobfish api" } ] } diff --git a/tests/testthat/2025.09.0/__api__/v1/search/content-eaf9f2.json b/tests/testthat/2025.09.0/__api__/v1/search/content-eaf9f2.json index 346f89d4..aa91191c 100644 --- a/tests/testthat/2025.09.0/__api__/v1/search/content-eaf9f2.json +++ b/tests/testthat/2025.09.0/__api__/v1/search/content-eaf9f2.json @@ -1,3 +1,4 @@ +// Used in test-content.R { "total": 3, "current_page": 2, @@ -5,58 +6,7 @@ { "guid": "abc12345", "name": "blobfish-report", - "title": "blobfish report", - "description": "", - "access_type": "all", - "locked": false, - "locked_message": "", - "connection_timeout": null, - "read_timeout": null, - "init_timeout": null, - "idle_timeout": null, - "max_processes": null, - "min_processes": null, - "max_conns_per_process": null, - "load_factor": null, - "memory_request": null, - "memory_limit": null, - "cpu_request": null, - "cpu_limit": null, - "amd_gpu_limit": null, - "nvidia_gpu_limit": null, - "service_account_name": null, - "default_image_name": null, - "default_environment_guid": null, - "created_time": "2024-08-29T17:52:30Z", - "last_deployed_time": "2025-09-25T17:26:05Z", - "bundle_id": "306864", - "app_mode": "python-shiny", - "content_category": "", - "parameterized": false, - "environment_guid": null, - "cluster_name": "Local", - "image_name": null, - "r_version": null, - "py_version": "3.10.17", - "quarto_version": null, - "r_environment_management": null, - "default_r_environment_management": null, - "py_environment_management": true, - "default_py_environment_management": null, - "run_as": null, - "run_as_current_user": false, - "owner_guid": "c2250bb4", - "content_url": "https://connect.example/content/abc12345/", - "dashboard_url": "https://connect.example/connect/#/apps/abc12345", - "app_role": "none", - "id": "57138", - "owner": { - "guid": "c2250bb4", - "username": "toph_allen", - "first_name": "Toph", - "last_name": "Allen" - }, - "public_content_status": null + "title": "blobfish report" } ] } diff --git a/tests/testthat/test-content.R b/tests/testthat/test-content.R index 9a5454f4..8c941d62 100644 --- a/tests/testthat/test-content.R +++ b/tests/testthat/test-content.R @@ -478,8 +478,8 @@ with_mock_dir("2025.09.0", { test_that("content search returns the expected list of content", { res <- search_content(client, q = "sea bream") expect_equal( - purrr::map_chr(res, "owner_guid"), - c("c2250bb4", "c2250bb4") + purrr::map_chr(res, "guid"), + c("c9f68287", "53032a0e") ) expect_equal( purrr::map_chr(res, "title"), From 9972d0ca2ecc029322c8d3bccf5f366be6630a65 Mon Sep 17 00:00:00 2001 From: Toph Allen Date: Fri, 3 Oct 2025 12:56:05 -0400 Subject: [PATCH 8/9] extract inner function to test explicitly. --- R/content.R | 38 +++++++++++++++++------------------ tests/testthat/test-content.R | 15 ++++++++++++++ 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/R/content.R b/R/content.R index 2174e56e..4ba1ae6d 100644 --- a/R/content.R +++ b/R/content.R @@ -1589,25 +1589,6 @@ search_content <- function( ) { error_if_less_than(client$version, "2024.04.0") - .search_content <- function( - client, - q, - page_number = 1, - page_size = 500, - include - ) { - path <- v1_url("search", "content") - - query <- list( - q = q, - page_number = page_number, - page_size = page_size, - include = include - ) - - client$GET(path, query = query) - } - page_offset( client, req = .search_content( @@ -1621,3 +1602,22 @@ search_content <- function( ) ) } + +.search_content <- function( + client, + q, + page_number = 1, + page_size = 500, + include +) { + path <- v1_url("search", "content") + + query <- list( + q = q, + page_number = page_number, + page_size = page_size, + include = include + ) + + client$GET(path, query = query) +} diff --git a/tests/testthat/test-content.R b/tests/testthat/test-content.R index 8c941d62..39512a60 100644 --- a/tests/testthat/test-content.R +++ b/tests/testthat/test-content.R @@ -510,6 +510,21 @@ with_mock_dir("2025.09.0", { ) ) }) + + test_that("the inner .search_content() func calls the endpoint correctly", { + without_internet( + expect_GET( + .search_content( + client, + q = "bream", + page_number = 2, + page_size = 20, + include = "owner" + ), + "https://connect.example/__api__/v1/search/content?q=bream&page_number=2&page_size=20&include=owner" + ) + ) + }) }) test_that("content search errors on Connect < 2024.04.0", { From 4f086148b3e43288267d3b9428acfc99868dcafb Mon Sep 17 00:00:00 2001 From: Toph Allen Date: Fri, 3 Oct 2025 13:07:07 -0400 Subject: [PATCH 9/9] fix lint --- tests/testthat/test-content.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-content.R b/tests/testthat/test-content.R index 39512a60..1197f9b3 100644 --- a/tests/testthat/test-content.R +++ b/tests/testthat/test-content.R @@ -511,7 +511,7 @@ with_mock_dir("2025.09.0", { ) }) - test_that("the inner .search_content() func calls the endpoint correctly", { + test_that("the inner .search_content() func calls the endpoint correctly", { without_internet( expect_GET( .search_content(