Skip to content

Return error when foreign key insert fails#72

Merged
rmulhol merged 1 commit intostagingfrom
return-fk-err
Dec 17, 2019
Merged

Return error when foreign key insert fails#72
rmulhol merged 1 commit intostagingfrom
return-fk-err

Conversation

@rmulhol
Copy link
Copy Markdown
Contributor

@rmulhol rmulhol commented Dec 16, 2019

Thanks @m0ar for noticing this issue!

Ideally I'd love to have tests to hedge against regressions here, but I was having trouble coming up for an effective strategy for doing so. Normally I'd mock the namespace that inserts an ilk or address, but those aren't behind an interface right now (maybe worth considering?). Some things I tried:

  • passing null values for the relevant topic - seems to happily insert a zero-valued field (problem?)
  • passing a null db - results on a panic on the call to db.Get (maybe we need a null check on the db in converters that use it?)

Would welcome ideas!

Copy link
Copy Markdown
Contributor

@gslaughl gslaughl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Pretty sure I'm responsible for most of these, because I didn't bother to figure out what ErrCouldNotCreateFK was doing before I used it. Lesson learned!

This does seem difficult to test. I guess technically the cleanest solution would be to hide shared.GetOrCreateAddress etc. behind an interface like you mentioned, but tbh that hardly seems worthwhile just to test that an error is being returned. It seems simple enough that we don't need to invest much time into testing it, although I can see why that's ironic coming from someone who repeatedly messed it up 😅

@rmulhol rmulhol merged commit d15e04b into staging Dec 17, 2019
@rmulhol rmulhol deleted the return-fk-err branch December 17, 2019 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants