2023-04-18 15:13:49 +00:00
|
|
|
package cmdio
|
|
|
|
|
|
|
|
import (
|
2023-09-08 12:07:22 +00:00
|
|
|
"context"
|
2023-04-18 15:13:49 +00:00
|
|
|
"testing"
|
|
|
|
|
2023-05-16 16:35:39 +00:00
|
|
|
"github.com/databricks/cli/libs/flags"
|
2023-04-18 15:13:49 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAskFailedInJsonMode(t *testing.T) {
|
|
|
|
l := NewLogger(flags.ModeJson)
|
2023-08-15 14:50:20 +00:00
|
|
|
_, err := l.Ask("What is your spirit animal?", "")
|
2023-04-18 15:13:49 +00:00
|
|
|
assert.ErrorContains(t, err, "question prompts are not supported in json mode")
|
|
|
|
}
|
2023-09-08 12:07:22 +00:00
|
|
|
|
|
|
|
func TestAskChoiceFailsInJsonMode(t *testing.T) {
|
|
|
|
l := NewLogger(flags.ModeJson)
|
|
|
|
ctx := NewContext(context.Background(), l)
|
|
|
|
|
|
|
|
_, err := AskSelect(ctx, "what is a question?", []string{"b", "c", "a"})
|
|
|
|
assert.EqualError(t, err, "question prompts are not supported in json mode")
|
|
|
|
}
|