From 016efe592323fcc79848f520dd95589269b0ad2c Mon Sep 17 00:00:00 2001 From: Jake Swenson Date: Sat, 15 May 2021 21:22:29 -0700 Subject: feat: adding support for running API tests in CI (using my API token...) (#2) --- src/lib.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index 3438749..8aeeb62 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,10 +110,19 @@ mod tests { }; use crate::{Identifiable, NotionApi}; - const TEST_TOKEN: &'static str = include_str!(".api_token"); + fn test_token() -> String { + let token = { + if let Some(token) = std::env::var("NOTION_API_TOKEN").ok() { + token + } else { + include_str!(".api_token").to_string() + } + }; + token.trim().to_string() + } fn test_client() -> NotionApi { - NotionApi::new(TEST_TOKEN.trim().to_string()).unwrap() + NotionApi::new(test_token()).unwrap() } #[tokio::test] -- cgit v1.2.3