Skip to content
  • maxice8's avatar
    feat(pkg/prompt/stubber): allow passing an error as Value · 70672aff
    maxice8 authored
    this allows testing error paths in code:
    
    Pass an `error` type as the Value, it will be reflect-checked if it is
    an error, and be returned
    
    ```golang
    as, restoreAsk := prompt.InitAskStubber()
    defer restoreAsk()
    
    as.Stub([]*prompt.QuestionStub{
        {
            Name:  "assignee",
            Value: errors.New("meant to fail"),
        },
    })
    ```
    
    Example code that will benefit:
    
    ```golang
    var confirmAnswers []string
    err := prompt.MultiSelect(&confirmAnswers, "metadata", "Which metadata types to add?", options)
    if err != nil {
        return nil, fmt.Errorf("could not prompt: %w", err)
    }
    ```
    70672aff