Skip to content

Commit

Permalink
[tests] provide testsetup function and use it. Can be checked with `s…
Browse files Browse the repository at this point in the history
…topifnot(ts == as.POSIXct("2023-07-20 23:32:14", tz = "UTC"))` (#857)
  • Loading branch information
JanMarvin authored Nov 23, 2023
1 parent e3355ef commit ff44f24
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 12 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ RoxygenNote: 7.2.3
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 3
Config/testthat/parallel: true
Config/testthat/start-first: aaa
19 changes: 19 additions & 0 deletions tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -1024,3 +1024,22 @@ testfile_path <- function(x, replace = FALSE) {
return(fl)
}
}


testsetup <- function() {

if (is.null(getOption("openxlsx2.datetimeCreated"))) {
testthat::test_that("testsetup", {

options("openxlsx2.datetimeCreated" = as.POSIXct("2023-07-20 23:32:14", tz = "UTC"))

wb <- wb_workbook()

exp <- "2023-07-20T23:32:14Z"
got <- wb$get_properties()[["datetime_created"]]
testthat::expect_equal(exp, got)

})
}

}
11 changes: 0 additions & 11 deletions tests/testthat/test-aaa.R

This file was deleted.

1 change: 1 addition & 0 deletions tests/testthat/test-asserts.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
testsetup()

test_that("assert_class() works", {
expect_null(assert_class(2L, "integer"))
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-base_font.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
testsetup()

test_that("get_base_font works", {
wb <- wb_workbook()
expect_equal(
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-class-chart-sheet.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
testsetup()

test_that("class wbChartSheet works", {

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-class-color.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
testsetup()

test_that("class color works", {
expect_null(assert_color(wb_colour()))
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-class-comment.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
testsetup()

test_that("class wbComment works", {
expect_null(assert_comment(wb_comment()))
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-class-hyperlink.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
testsetup()

test_that("class Hyperlink works", {
expect_null(assert_hyperlink(wb_hyperlink()))
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-class-workbook-utils.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
testsetup()

test_that("waivers works with $add_worksheet()", {
wb <- wb_workbook()
expect_identical(wb$.__enclos_env__$private$current_sheet, 0L)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-class-workbook-wrappers.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
testsetup()

# wb_workbook() -----------------------------------------------------------

Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-class-workbook.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

testsetup()

test_that("Workbook class", {
expect_null(assert_workbook(wb_workbook()))
})
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-wb_styles.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
testsetup()

test_that("wb_clone_sheet_style", {

# clone style to empty sheet (creates cells and style)
Expand Down

0 comments on commit ff44f24

Please sign in to comment.