Skip to content

Commit

Permalink
Fix tests on windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
plietar committed Apr 3, 2024
1 parent 6527497 commit 36facd6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions tests/testthat/test-location-path.R
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,11 @@ test_that("Can read metadata files with a trailing newline", {
path <- file.path(root$path, ".outpack", "metadata", id)

# Calling writeLines adds the trailing newline and mimicks the old orderly2
# behaviour.
# behaviour. The size will be one or two bytes bigger than the actual data,
# depending on whether the newline is `\n` or `\r\n`.
old_size <- file.info(path)$size
writeLines(read_string(path), path)
expect_equal(file.info(path)$size, old_size + 1)
expect_gte(file.info(path)$size, old_size + 1)

# Reading the metadata from a location at that path correctly strips the
# newline and hashes correctly.
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/test-util.R
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ test_that("read_string strips newlines", {
writeLines(c("", "12345678"), path)

# 8 characters, a leading newline and a trailing one
expect_equal(file.info(path)$size, 10)
# Each newline may be one of two bytes each, depending on the platform.
expect_gte(file.info(path)$size, 10)

result <- expect_silent(read_string(path))
expect_equal(result, "12345678")
Expand Down

0 comments on commit 36facd6

Please sign in to comment.