Tests: setup and check keyring
Change-Id: I9b71d0b3ee486f403dc72abcc67c2104627f9cd4
diff --git a/tests/testthat.R b/tests/testthat.R
index 992d351..b8813ea 100644
--- a/tests/testthat.R
+++ b/tests/testthat.R
@@ -1,4 +1,16 @@
library("testthat")
library("RKorAPClient")
+# Set up keyring for testing to avoid interactive password prompts
+if (requireNamespace("keyring", quietly = TRUE)) {
+ # Use environment backend for testing to avoid password prompts
+ if (!nzchar(Sys.getenv("KEYRING_BACKEND"))) {
+ Sys.setenv("KEYRING_BACKEND" = "env")
+ }
+ # Set empty password for file backend if needed
+ if (!nzchar(Sys.getenv("KEYRING_PASS"))) {
+ Sys.setenv("KEYRING_PASS" = "")
+ }
+}
+
test_check("RKorAPClient")