Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenturner committed Aug 18, 2024
1 parent ae2b6a6 commit 91ee1e0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ Imports:
tinytable
Suggests:
knitr,
markdown
markdown,
testthat (>= 3.0.0)
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Config/testthat/edition: 3
12 changes: 12 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
# * https://testthat.r-lib.org/articles/special-files.html

library(testthat)
library(biorecap)

test_check("biorecap")
22 changes: 22 additions & 0 deletions tests/testthat/test-biorecap.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
test_that("build_prompt_preprint", {
expect_silent(res <- build_prompt_preprint(title="A great paper", abstract="This is the abstract."))
expect_true(is.character(res))
expect_error(build_prompt_preprint(title="A great paper", abstract="This is the abstract.", nsentences=0))
})

test_that("get_preprints", {
expect_silent(preprints <- get_preprints(subject="all"))
expect_true(inherits(preprints, "preprints"))
expect_true(inherits(preprints, "tbl"))
expect_error(get_preprints(subject=123))
expect_error(get_preprints(subject="invalid"))
})

test_that("add_prompt", {
expect_silent(res <- add_prompt(example_preprints))
expect_true(inherits(res, "preprints_prompt"))
expect_true(inherits(res, "tbl"))
expect_error(expect_warning(add_prompt(iris)))
expect_error(add_prompt("invalid"))
})

8 changes: 8 additions & 0 deletions tests/testthat/test-data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test_that("subjects", {
expect_true(is.character(subjects))
expect_identical(length(subjects), 27L)
})
test_that("example_preprints", {
expect_true(is.data.frame(example_preprints))
expect_identical(colnames(example_preprints), c("subject", "title", "url", "abstract", "prompt", "summary"))
})

0 comments on commit 91ee1e0

Please sign in to comment.