Skip to content

Commit

Permalink
use md plus politely #16
Browse files Browse the repository at this point in the history
  • Loading branch information
maxheld83 committed Dec 8, 2020
1 parent 8b9aaa9 commit 2efc2da
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
env:
MUGGLE_PKG_NAME: ${{ github.event.repository.name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
crossref_plus: ${{ secrets.CR_MD_PLUS_TOKEN }}
# TODO commiter email here https://github.com/subugoe/metar/issues/110
crossref_email: [email protected]
steps:
- uses: actions/checkout@v2
- name: Cache R Packages
Expand Down
5 changes: 4 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ Suggests:
testthat,
subugoetheme,
shinycaas,
rmarkdown
rmarkdown,
bench (>= 1.1.1)
URL: https://subugoe.github.io/metacheck, https://github.com/subugoe/metacheck
BugReports: https://github.com/subugoe/metacheck/issues
Remotes:
subugoe/[email protected],
subugoe/[email protected],
subugoe/rcrossref@51d036808c1dc1f46cf1bad1b136e97ad213e162
rstudio/shinyvalidate
Config/testthat/edition: 3
3 changes: 3 additions & 0 deletions R/test_helper.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
is_valid_email <- function(x) {
grepl("^\\s*[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}\\s*$", as.character(x), ignore.case=TRUE)
}
4 changes: 4 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(metacheck)

test_check("metacheck")
22 changes: 22 additions & 0 deletions tests/testthat/test-cr_auth.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
test_that("crossref metadata is enabled", {
# could not capture with header response from rcrossref,
# so result must be inspected manually in logs
rcrossref::cr_abstract('10.1109/TASC.2010.2088091', verbose = TRUE)
expect_equal(1, 1)
})

test_that("crossref metadata plus is faster", {
skip("Test does not work; times are often the same.")
with_mdplus <- bench::bench_time(
rcrossref::cr_agency(sample_dois[1:10], .progress = "text")
)["real"]
withr::local_envvar(.new = c("crossref_plus" = ""))
without_mdplus <- bench::bench_time(
rcrossref::cr_agency(sample_dois[1:10], .progress = "text")
)["real"]
expect_lte(with_mdplus, without_mdplus)
})

test_that("metacheck declares polite user agent", {
expect_true(is_valid_email(Sys.getenv("crossref_email")))
})

0 comments on commit 2efc2da

Please sign in to comment.