Skip to content

Commit 92685f5

Browse files
committed
begin testing
1 parent b102477 commit 92685f5

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

DESCRIPTION

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Suggests:
3737
mirai,
3838
nanoparquet,
3939
quarto,
40-
readr
40+
readr,
41+
testthat (>= 3.0.0)
4142
VignetteBuilder: quarto
4243
URL: https://laughing-spoon-ywk3ewq.pages.github.io/
44+
Config/testthat/edition: 3

R/api_docs.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ api_doc_setting <- function(api, doc_type, doc_path) {
3535
api$doc_type <- doc_type
3636
}
3737
if (!missing(doc_path)) {
38-
api_doc_path <- doc_path
38+
api$doc_path <- doc_path
3939
}
4040
api
4141
}

tests/testthat.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is part of the standard setup for testthat.
2+
# It is recommended that you do not modify it.
3+
#
4+
# Where should you do additional test configuration?
5+
# Learn more about the roles of various files in:
6+
# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview
7+
# * https://testthat.r-lib.org/articles/special-files.html
8+
9+
library(testthat)
10+
library(plumber2)
11+
12+
test_check("plumber2")

tests/testthat/test-aaa.R

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
test_that("as_openapi_path modifies the path correctly", {
2+
expect_equal(as_openapi_path("/test/nothing"), "/test/nothing")
3+
expect_equal(as_openapi_path("/test/<arg>"), "/test/{arg}")
4+
expect_equal(
5+
as_openapi_path("/test/<arg>/and/<arg2>"),
6+
"/test/{arg}/and/{arg2}"
7+
)
8+
expect_equal(
9+
as_openapi_path("/test/<arg:number>/and/<arg2:[integer]>"),
10+
"/test/{arg}/and/{arg2}"
11+
)
12+
})
13+
14+
test_that("as_routr_path modifies the path correctly", {
15+
expect_equal(as_routr_path("/test/nothing"), "/test/nothing")
16+
expect_equal(as_routr_path("/test/<arg>"), "/test/:arg")
17+
expect_equal(
18+
as_routr_path("/test/<arg>/and/<arg2>"),
19+
"/test/:arg/and/:arg2"
20+
)
21+
expect_equal(
22+
as_routr_path("/test/<arg:number>/and/<arg2:[integer]>"),
23+
"/test/:arg/and/:arg2"
24+
)
25+
})

0 commit comments

Comments
 (0)