brianc / node-pg-types

Type parsing for node-postgres
268 stars 55 forks source link

test: Convert binary test vectors via Buffer.from(...) #89

Closed sehrope closed 5 years ago

sehrope commented 5 years ago

While working on a more direct handling of a fix for #86 I noticed that some of the binary protocol test vectors are not actually Buffers. The parser code mostly treats things as arrays so it does not break anything for now but ran into an issue trying to use Buffer functions like readInt16BE(...) in new code.

This PR leaves the tests alone but automatically converts anything that's not a Buffer to one prior to running a binary format test. I think this is a nice compromise as the parser code can rely on its contract of the input value being a Buffer and the test code can continue to use shorthand like [1,2,3,4] for a 4-byte array rather than changing everything to Buffer.from(...).