From 09555d256b495711e9f02e1eb15d3553931cadd3 Mon Sep 17 00:00:00 2001 From: Matthew Lynch Date: Wed, 26 Jul 2023 14:55:20 -0500 Subject: [PATCH] add tests for shinyapps.io deploymentTarget and NEWS.md entry for 932 bugfix --- NEWS.md | 3 ++ tests/testthat/test-deploymentTarget.R | 70 ++++++++++++++------------ 2 files changed, 40 insertions(+), 33 deletions(-) diff --git a/NEWS.md b/NEWS.md index 42a12afa..c81ec11d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # rsconnect (development version) +* Fixed redeployments to shinyapps.io where `appName` is provided, but no local + record of the deployment exists. (#932) + * `deployApp()` and `writeManifest()` now error if your library and `renv.lock` are out-of-sync. Previously it always used what was defined in the `renv.lock` but that was (a) slow and (b) could lead to different results than what you diff --git a/tests/testthat/test-deploymentTarget.R b/tests/testthat/test-deploymentTarget.R index 9f242b3c..c686cad7 100644 --- a/tests/testthat/test-deploymentTarget.R +++ b/tests/testthat/test-deploymentTarget.R @@ -187,42 +187,46 @@ test_that("default title is the empty string", { }) test_that("can find existing application on server & use it", { - local_temp_config() - addTestServer() - addTestAccount("ron") - local_mocked_bindings( - applications = function(...) data.frame( - name = "my_app", - id = 123, - url = "http://example.com/test", - stringsAsFactors = FALSE - ), - shouldUpdateApp = function(...) TRUE - ) - - app_dir <- withr::local_tempdir() - target <- deploymentTarget(app_dir, appName = "my_app") - expect_equal(target$appId, 123) + for (server in c("example.com", "shinyapps.io")) { + local_temp_config() + addTestServer() + addTestAccount("ron", server = server) + local_mocked_bindings( + applications = function(...) data.frame( + name = "my_app", + id = 123, + url = "http://example.com/test", + stringsAsFactors = FALSE + ), + shouldUpdateApp = function(...) TRUE + ) + + app_dir <- withr::local_tempdir() + target <- deploymentTarget(app_dir, appName = "my_app", server = server) + expect_equal(target$appId, 123) + } }) test_that("can find existing application on server & not use it", { - local_temp_config() - addTestServer() - addTestAccount("ron") - local_mocked_bindings( - applications = function(...) data.frame( - name = "my_app", - id = 123, - url = "http://example.com/test", - stringsAsFactors = FALSE - ), - shouldUpdateApp = function(...) FALSE - ) - - app_dir <- withr::local_tempdir() - target <- deploymentTarget(app_dir, appName = "my_app") - expect_equal(target$appName, "my_app-1") - expect_equal(target$appId, NULL) + for (server in c("example.com", "shinyapps.io")) { + local_temp_config() + addTestServer() + addTestAccount("ron", server = server) + local_mocked_bindings( + applications = function(...) data.frame( + name = "my_app", + id = 123, + url = "http://example.com/test", + stringsAsFactors = FALSE + ), + shouldUpdateApp = function(...) FALSE + ) + + app_dir <- withr::local_tempdir() + target <- deploymentTarget(app_dir, appName = "my_app", server = server) + expect_equal(target$appName, "my_app-1") + expect_equal(target$appId, NULL) + } }) # defaultAppName ----------------------------------------------------------