I would like to be able to run a similar test on the API when deployed on my RStudio connect server, but I'm not sure how to call it since I would need to pass it my username/password.
Hi, the API authentication in RStudio Connect is done via an API Key, here is the link to the article: API Keys - RStudio Connect: User Guide. Once you setup your personal key, you would use that in the httr::GET() command as your password argument.
Also, I would also suggest to use a regular /R script instead of one in the /test folder. That way you can eventually create a function that does both, deploy the new app, and then test it. Something similar to devtools::release(). That function does the checks and releases to CRAN, and it is expected to be run in an interactive R session. In your case, it could also ask for your password/Key using the rstudioapi::askForPassword() command.
edit: deploying to TEST server and running tests on the TEST server would be nice. I'm not sure if I could do it with a function because the API is only updated every 15 minutes, so the function would have to wait until it has been updated.