"has special handling for CRAN packages"
"packages installed from other repos get correctly named"

# Stock responses for certain endpoints. Can still be overridden by tests.
mockServer$addResponse <- function(methodAndPath, response) {
for (pathRegex in names(mockServer$responses)) {
for (respProperty in names(responseSupplement)) {
response$content <- jsonlite::toJSON(response$content, auto_unbox = TRUE)
stop(paste("No mocked response defined for", methodAndPath))
configureTestAccount <- function(server = "posit.cloud", name = NULL) {
error = function(e) { existingAccount <- NULL }
content = function(methodAndPath, match, ...) {
end <- attr(match, "match.length")[2] + match[2]
output_id <- strtoi(substr(methodAndPath, match[2], end))
application_id <- strtoi(substr(methodAndPath, match[2], end))
restoreOpt <- options(rsconnect.http = mockServer$impl)
test_that("Get application output trashed", {
content = function(methodAndPath, match, contentFile, ...) {
app <- client$createApplication("test app", "unused?", "unused?", "unused?", "shiny")
app <- client$createApplication("test app", "unused?", "unused?", "unused?", "static")
test_that("Create static server-side-rendered application", {
app <- client$createApplication("test app", "unused?", "unused?", "unused?", "quarto-static")
test_that("deployApplication updates the parent project", {
application_id <- substr(methodAndPath, match[2], end)
test_that("Create static RMD application", {
app <- client$createApplication("test app", "unused?", "unused?", "1", "rmd-static")
test_that("Create application with linked source project", {
content = function(methodAndPAth, match, contentFile, ...) {
test_that("deploymentTargetForApp() results in correct Cloud API calls", {
"name" = paste("testthat app", application_id)
deployAppMockServerFactory <- function(expectedAppType, outputState) {
# An attempt to search for preexisting applications with the same name.
# This call should change, see https://github.com/rstudio/rsconnect/issues/808
name = paste("testthat app", application_id),
# Fetch existing output when re-deploying from .dcf data
test_that("deployApp() for shiny results in correct Cloud API calls", {
mock <- deployAppMockServerFactory(expectedAppType = "connect", outputState = "active")
# Remove local deployment info at end for reproducibility and tidiness.
withr::defer(forgetDeployment(appPath = sourcePath, force = TRUE))
# deploy again to test existing deployment path
# Start over, add another posit.cloud account and test again with that environment
forgetDeployment(appPath = sourcePath, force = TRUE)
extraLocalAccount <- configureTestAccount(name = "testthat-superfluous-account")
test_that("deployDoc() results in correct Cloud API calls", {
mock <- deployAppMockServerFactory(expectedAppType = "static", outputState = "active")
paste(sourcePath, "slideshow.html", sep = "/"),