Commit graph

14 commits

Author SHA1 Message Date
Mislav Marohnić
a33b5a55c4 Have NewAskStubber perform auto-cleanup 2022-01-14 18:52:00 +01:00
Mislav Marohnić
c839d3ba1d Check for unused ask stubs at the end of the test 2022-01-13 12:23:42 +01:00
Mislav Marohnić
8e64c149e1 Return errors in ask stubber instead of panicking 2022-01-13 11:58:58 +01:00
Mislav Marohnić
0cb4b7aaef Improve SurveyAskOne stub error messages 2022-01-13 11:16:58 +01:00
Mislav Marohnić
3c443efbed Improve Survey prompt stubber for tests
Both SurveyAsk and SurveyAskOne methods now share the same sets of
stubs, making it possible to change which of these methods is used in
the implementation without breaking tests.

A new method `AskStubber.StubPrompt("<prompt>")` is added as test helper
to supersede old Stub and StubOne methods. The new helper matches on
prompt messages rather than on field names, enabling tests to be written
based on what the user would see rather than coupling to implementation
details.

The new stubber also allows verifying whether a Select or MultiSelect
was rendered with the expected set of options. Furthermore, if a stubbed
value is not present among those options, the stubber will panic instead
of continuing normally.

Stubbed Selects with an int instead of a string target receiver are now
transparently handled. The values for Select stubs are always strings in
tests, but the stubber will write an int answer if the receiver expects
one as a selected index instead of a selected string value.

Lastly, this set of changes improves test resiliency since the stubs are
now matched based on prompt message (or field name for legacy stubs
created with Stub) instead of sequentially, enabling the implementation
to reorder the prompts without breaking existing tests.
2022-01-12 23:51:21 +01:00
vilmibm
395355d075 make prompt.Confirm stubbable 2021-06-08 15:49:37 -05:00
Mislav Marohnić
2b4372bc3a AskStubber now throws a more descriptive error when stubs do not match 2020-12-03 17:51:58 +01:00
vilmibm
ef52376fe0 fix survey invocation 2020-11-13 10:35:32 -08:00
vilmibm
f5277e452e get everything working 2020-11-12 12:03:32 -08:00
Mislav Marohnić
eee32f324c Fix AskStubber erroring out when there are more asks than stubs 2020-09-23 19:55:11 +02:00
vilmibm
35f18b6c02 gh auth login 2020-08-06 12:43:35 -05:00
vilmibm
245c3c7425 move survey helper and test helpers to prompt pkg 2020-07-27 17:00:09 -05:00
vilmibm
dadcf4ba96 add prompt.StubConfirm 2020-07-27 10:00:19 -05:00
vilmibm
c34054bdc8 isolate repo create command 2020-07-24 12:26:27 -05:00