Skip to content

Commit

Permalink
don't leave test.sav behind
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Oct 6, 2023
1 parent 4e7967b commit c37a80a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
14 changes: 14 additions & 0 deletions tests/testthat/_snaps/data_write.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# data_write, SPSS, mixed types of labelled vectors

Code
data_write(d, "test.sav")
Message <simpleMessage>
Preparing data file: converting variable types.

# data_write, existing variable label but missing value labels

Code
data_write(d, tmp)
Message <simpleMessage>
Preparing data file: converting variable types.

8 changes: 6 additions & 2 deletions tests/testthat/test-data_write.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ test_that("data_write, SPSS, mixed types of labelled vectors", {
d$c <- assign_labels(d$c, variable = "Third", values = c("ey", "bee", "see"))

# expect message, but no error
expect_message(data_write(d, "test.sav"), regex = "Preparing")
skip_if_not_installed("withr")
withr::with_tempdir(code = {
expect_snapshot(data_write(d, "test.sav"))
})

})


Expand Down Expand Up @@ -146,7 +150,7 @@ test_that("data_write, existing variable label but missing value labels", {
)
d$a <- assign_labels(d$a, variable = "First")
# expect message, but no error
expect_message(data_write(d, tmp), regex = "Preparing")
expect_snapshot(data_write(d, tmp))

# check if data is really the same
d2 <- data_read(tmp)
Expand Down

0 comments on commit c37a80a

Please sign in to comment.