16 Commits

Author SHA1 Message Date
Billy Keyes 071689e91f Test with Go 1.19, upgrade golangci-lint (#35)
The previous version of the golangci-lint action would install its own
version of Go, which eventually conflicted with the old pinned version
of the linter I was using. Upgrade the action to avoid this, but also
update Go and the linter while I'm here.
2022-09-30 22:41:17 -07:00
Billy Keyes 4fa9801742 Check for leftover content after a full delete (#9)
When applying a text fragment that deletes all content in the file, make
sure there is no content left in the source after using all the lines in
the fragment. If there is is extra content, it's a conflict: something
added more lines to the file after generating the patch.
2020-05-03 13:39:08 -07:00
Billy Keyes 9fc14fddb0 Add tests for file-level application
Also refactor the apply tests to use a common type now that there are
three variants that do almost the same thing for each test.
2020-01-27 22:35:13 -08:00
Billy Keyes a34334d6ef Add error tests for BinaryFragment#Apply
These cover some of the possible errors with delta fragments. Many of
the same tests could be implemented slightly easier by testing the
helper functions, but the infrastructure is already set up to test the
full function.

This is made easier by the bin.go CLI, which can parse and encode binary
patch data. Once parsed, fragments were manipulated with truncate and
dd, encoded, and placed in the patch files.
2020-01-16 22:43:56 -08:00
Billy Keyes 194589f001 Add test for large binary delta application
This ensures a default size is used for large copy instructions.
2020-01-16 21:52:41 -08:00
Billy Keyes c50036a466 Abstract common file loading in apply tests 2020-01-16 21:52:41 -08:00
Billy Keyes 79aa2a9a77 Add positive tests for BinaryFragment#Apply
Covers basic literal and delta application. Input files were created by
using dd and the 'conv=notrunc' option to modify sections of files
created from /dev/urandom. All file start with two null bytes to
convince Git they are binary.
2020-01-16 21:52:40 -08:00
Billy Keyes 1b341e0693 Add error tests for TextFragment#ApplyStrict
These cover the errors that can happen with a single fragment and no
additional manipulation by the caller of ApplyStrict.
2020-01-12 22:09:08 -08:00
Billy Keyes 6a055aa600 Add exact line test for TextFragment#ApplyStrict
This ensures the line number is used and application isn't based only on
matching context lines.
2020-01-12 22:08:15 -08:00
Billy Keyes 7bd4e0bb0e Fix EOF handling in TextFragment#ApplyStrict
io.EOF was not properly accounted for when dealing with patches that are
missing trailing newline characters.
2020-01-09 22:05:24 -08:00
Billy Keyes 02f7ff4f79 Add positive tests for TextFragment#ApplyStrict
These cover all of the cases (I think) where application should succeed.
2020-01-08 23:04:44 -08:00
Billy Keyes 16539ad031 Add tests for parsing full binary fragments 2019-04-14 19:18:08 -07:00
Billy Keyes 69e4444419 Return preamble content when parsing files
This allows callers to provide patches with commit or email headers and
then retrieve that leading content for additional parsing without
having to identify where the first file in the patch starts.
2019-04-07 19:57:11 -07:00
Billy Keyes 07e5314a7c Remove second commit header from test file
While it's cool that this works, in a multi-file patch each file
immediately follow the final fragment of the previous file.
2019-04-07 17:49:15 -07:00
Billy Keyes 09c686917c Add test for multiple files in one patch
For simplicity, use the same fragments in both of these files and in the
single file test.
2019-04-06 19:13:42 -07:00
Billy Keyes 47d923e573 Add simple full file parsing test
For now, this uses JSON to print objects on error, which is hard to
debug. It should probably use something like google/go-cmp instead,
because these objects are now too large for direct comparison.
2019-04-03 23:01:44 -07:00