Compile typed command runners
This commit is contained in:
@@ -60,6 +60,25 @@ func TestExecuteRunsTypedCommandsWithFreshInvocationState(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOmittedInputFactoryUsesExactPointerZeroValue(t *testing.T) {
|
||||
command := commandkit.NewCommand(commandkit.CommandSpec[*int]{
|
||||
Name: "run",
|
||||
Run: func(_ commandkit.Invocation, value *int) commandkit.Outcome {
|
||||
if value != nil {
|
||||
return commandkit.Failure(errors.New("omitted input factory allocated a pointer"))
|
||||
}
|
||||
return commandkit.Success()
|
||||
},
|
||||
})
|
||||
app, err := commandkit.New(commandkit.Identity{Name: "example"}, command)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if outcome := app.Execute(context.Background(), []string{"run"}, commandkit.Streams{}); outcome.Kind != commandkit.OutcomeSuccess {
|
||||
t.Fatalf("pointer zero value outcome = %#v", outcome)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteUsesFreshSessionForHelpAfterFlagBearingInvocation(t *testing.T) {
|
||||
type input struct {
|
||||
name commandkit.Supplied[string]
|
||||
|
||||
Reference in New Issue
Block a user