elliotchance / gedcom

👪 A Go library and CLI tools for encoding, decoding, traversing, merging, comparing, querying and publishing GEDCOM files.
MIT License
96 stars 21 forks source link

If spouse is already nil, short-circuit out. #311

Closed jazzboME closed 4 years ago

jazzboME commented 4 years ago

So I thought I had run all of the tests, but I obviously hadn't as the test for child_node is now failing -- with the actual failure being the doc.AddFamilyWithHusbandAndWife("F1", p1, nil) call.

This fixes that problem, by quietly returning if you try to SetWife() or SetHusband() with nil and it's already nil. While I was there I fixed some formatting, and used IsNil() for my tests.

Also added some explicit tests for AddFamilyWithHusbandAndWife() in the familyTests.

So really, really sorry about this -- I tripled checked that the tests were all OK this time.


This change is Reviewable

elliotchance commented 4 years ago

Hi @jazzboME that isn't your fault, it's mine. I had disabled the Travis CI build for pull requests so it was not running the tests to verify before I merged it in. Thanks for fixing this so quickly 👍

I have reenabled travis for future PRs so you can hack away with confidence!