feat: allow use of providers that don't return errors

This commit is contained in:
Alec Thomas
2025-01-30 13:39:31 +11:00
parent 9c08a58eb2
commit 4e1757c0e8
3 changed files with 35 additions and 3 deletions
+20
View File
@@ -2521,3 +2521,23 @@ func TestIssue483EmptyRootNodeNoRun(t *testing.T) {
assert.Error(t, err)
assert.Contains(t, err.Error(), "no command selected")
}
type providerWithoutErrorCLI struct {
}
func (p *providerWithoutErrorCLI) Run(name string) error {
if name == "Bob" {
return nil
}
return fmt.Errorf("name %s is not Bob", name)
}
func TestProviderWithoutError(t *testing.T) {
k := mustNew(t, &providerWithoutErrorCLI{})
kctx, err := k.Parse(nil)
assert.NoError(t, err)
err = kctx.BindToProvider(func() string { return "Bob" })
assert.NoError(t, err)
err = kctx.Run()
assert.NoError(t, err)
}