-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export and modify gm_default_email()
* Export it, because appears as a default in gm_auth(). * If GMAILR_EMAIL does not exist, fall back to gargle::gargle_oauth_email(). If nothing else, this makes lots of gargle documentation much more true and relevant to gmailr. * Create a new help topic for env vars that affect gmailr. This is going to gain more before we're done. * Test it.
- Loading branch information
Showing
9 changed files
with
83 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
test_that("gm_default_email() transmits GMAILR_EMAIL", { | ||
withr::local_envvar(GMAILR_EMAIL = "jenny@example.com") | ||
expect_equal(gm_default_email(), "jenny@example.com") | ||
}) | ||
|
||
test_that("gm_default_email() falls back to gargle::gargle_oauth_email()", { | ||
# unset GMAILR_EMAIL | ||
withr::local_envvar(GMAILR_EMAIL = NA) | ||
expect_equal(Sys.getenv("GMAILR_EMAIL"), "") | ||
|
||
withr::local_options(gargle_oauth_email = NULL) | ||
expect_null(gm_default_email()) | ||
|
||
withr::local_options(gargle_oauth_email = "*@example.com") | ||
expect_equal(gm_default_email(), "*@example.com") | ||
|
||
withr::local_options(gargle_oauth_email = TRUE) | ||
expect_true(gm_default_email()) | ||
}) |