You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
It is not, but unit-testing huh required some work when I was building it into our CLI. I wrote an 'answering machine' that supplies the input stream of huh inputs based on the output
Describe the solution you'd like
I'd love to write a test package that provides the user with 2 streams to give to huh's WithInput and WithOutput methods, with settings to respond to certain inputs. Maybe something like:
package main
import"github.com/charmbracelet/huh/huhtest"funcTestHuhForm_DoesWhatItIsSupposedToDo(t*testing.T) {
varformIn io.PipeReadervarformOut io.PipeWritervarclosefunc()
formIn, formOut, close=huhtest.NewAnsweringMachine().
AddResponse("How Are You Feeling?", "Amazing Thanks!").
AddResponse("Would you like a drink?", huhtest.ConfirmNegative).
Times(2).
AddResponse("Please pick all options that apply", []string{"a", "b", "c"}).
Once().
AddResponses("Are you OK? (gonna ask you twice)", []string{"yes", "yes for sure"}).
Start()
// Alternative available: SetResponses(map[string][]string)deferformIn.Close()
deferformOut.Close()
deferclose()
// Acterr:=myForm.WithInput(formIn).WithOutput(formOut).Run()
// Assert// [...]
}
Describe alternatives you've considered
Turning it into a separate library instead of incorporating it as a contribution here, which I'm fine with as well
Additional context
I'm asking it to see if this is the direction that you might be interested in exploring and what your thoughts are on such a framework
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
It is not, but unit-testing
huh
required some work when I was building it into our CLI. I wrote an 'answering machine' that supplies the input stream of huh inputs based on the outputDescribe the solution you'd like
I'd love to write a test package that provides the user with 2 streams to give to
huh
'sWithInput
andWithOutput
methods, with settings to respond to certain inputs. Maybe something like:Describe alternatives you've considered
Turning it into a separate library instead of incorporating it as a contribution here, which I'm fine with as well
Additional context
I'm asking it to see if this is the direction that you might be interested in exploring and what your thoughts are on such a framework
The text was updated successfully, but these errors were encountered: