aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jake Swenson <jakeswenson@users.noreply.github.com> 2021-05-15 21:22:29 -0700
committerGravatar GitHub <noreply@github.com> 2021-05-15 21:22:29 -0700
commit016efe592323fcc79848f520dd95589269b0ad2c (patch)
tree54986e760e43e2c76cc4a9fb208ef2e1ad3e4d2e
parentc3a8b68989f6df0c3a4ebe56aeb7f160e8c7b580 (diff)
downloadnotion-016efe592323fcc79848f520dd95589269b0ad2c.tar.gz
notion-016efe592323fcc79848f520dd95589269b0ad2c.tar.zst
notion-016efe592323fcc79848f520dd95589269b0ad2c.zip
feat: adding support for running API tests in CI (using my API token...) (#2)
-rw-r--r--src/lib.rs13
1 files changed, 11 insertions, 2 deletions
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]