Skip to content

Commit

Permalink
adding some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
njahn82 committed Oct 23, 2017
1 parent 308f184 commit dd5ad2c
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/testthat/test_cr_agency.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,26 @@ test_that("cr_ageny fails correctly", {
expect_error(cr_agency(dois = cr_r(3), timeout_ms = 1))
})

test_that("cr_agency - email works", {
skip_on_cran()

Sys.setenv("crossref_email" = "name@example.com")
expect_is(cr_agency(dois = '10.1038/jid.2009.428'), "list")
})


test_that("cr_agency - email is validated", {
skip_on_cran()

Sys.setenv("crossref_email" = "name@example")
expect_error(cr_agency(dois = '10.1038/jid.2009.428'))
})

test_that("cr_agency - email NULL works", {
skip_on_cran()

Sys.setenv("crossref_email" = "")
expect_is(cr_agency(dois = '10.1038/jid.2009.428'), "list")
})

Sys.sleep(2)
22 changes: 22 additions & 0 deletions tests/testthat/test_cr_funders.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,27 @@ test_that("cr_funders fails correctly", {
"Resource not found")
})

test_that("cr_works - email works", {
skip_on_cran()

Sys.setenv("crossref_email" = "name@example.com")
expect_is(cr_funders(dois=c('10.13039/100000001')), "list")
})


test_that("cr_funders - email is validated", {
skip_on_cran()

Sys.setenv("crossref_email" = "name@example")
expect_error(cr_funders(dois=c('10.13039/100000001')))
})

test_that("cr_funders - email NULL works", {
skip_on_cran()

Sys.setenv("crossref_email" = "")
expect_is(cr_funders(dois=c('10.13039/100000001')), "list")
})

Sys.sleep(2)

23 changes: 23 additions & 0 deletions tests/testthat/test_cr_works.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,28 @@ test_that("cr_works - parses affiliation inside authors correctly", {
expect_named(aa$data$author[[1]], c("given", "family", "affiliation.name"))
})

test_that("cr_works - email works", {
skip_on_cran()

Sys.setenv("crossref_email" = "name@example.com")
a <- cr_works(query="NSF")
expect_is(a, "list")
})

test_that("cr_works - email is validated", {
skip_on_cran()

Sys.setenv("crossref_email" = "name@example")
expect_error(cr_works(query="NSF"))
})

test_that("cr_works - email NULL works", {
skip_on_cran()

Sys.setenv("crossref_email" = "")
a <- cr_works(query="NSF")
expect_is(a, "list")
})

Sys.sleep(2)

0 comments on commit dd5ad2c

Please sign in to comment.