Hello, first and foremost I apologise if I am missing something obvious that leads to this error, I'm new at R and there's many thing yet to learn!
Let's say for simplicity that I have a function csv_to_tsv() that reads an input csv file data.csv and then writes a new tab separated file with that data, data.tsv. I attempted to implement expect_snapshot_file() in order to keep a snapshot file as a standard in case I would want to change something in the function, as in going from write.table to readr::write_table, for instance. This is how I implemented it in testconvert.R:
The first time I run devtools::test() the snapshots are created and everytime I test again everything goes smoothly and tests are passed, as expected.
However, if I change git branches to work on something else and come back to this branch later, running devtools::test() fails:
Failure (testconvert.R:38:3): Converting CSV to TSV gives expected results
Snapshot of `save_tsv("data.csv")` to 'testconvert/datasnap.tsv' has changed
Run `testthat::snapshot_review('testconvert/')` to review changes
Checking the differences shows there aren't any... and most curiously, if I delete the previously created snapshots and run test() again, the new snapshots created are not even registered as modifications in the git branch, since they are exactly as the ones that were there before.
What could be the reason for this error? Is there some file metadata checking going on when comparing the files, or something of a similar nature?
Hello, first and foremost I apologise if I am missing something obvious that leads to this error, I'm new at R and there's many thing yet to learn!
Let's say for simplicity that I have a function
csv_to_tsv()
that reads an input csv filedata.csv
and then writes a new tab separated file with that data,data.tsv
. I attempted to implementexpect_snapshot_file()
in order to keep a snapshot file as a standard in case I would want to change something in the function, as in going fromwrite.table
toreadr::write_table
, for instance. This is how I implemented it intestconvert.R
:The first time I run
devtools::test()
the snapshots are created and everytime I test again everything goes smoothly and tests are passed, as expected.However, if I change git branches to work on something else and come back to this branch later, running
devtools::test()
fails:Checking the differences shows there aren't any... and most curiously, if I delete the previously created snapshots and run
test()
again, the new snapshots created are not even registered as modifications in the git branch, since they are exactly as the ones that were there before.What could be the reason for this error? Is there some file metadata checking going on when comparing the files, or something of a similar nature?