2022-03-24 01:54:32 +00:00
|
|
|
package commandctrl_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-03-24 21:17:52 +00:00
|
|
|
"testing"
|
|
|
|
|
2022-03-24 01:54:32 +00:00
|
|
|
"github.com/lmika/awstools/internal/common/ui/commandctrl"
|
|
|
|
"github.com/lmika/awstools/internal/common/ui/events"
|
|
|
|
"github.com/lmika/awstools/test/testuictx"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCommandController_Prompt(t *testing.T) {
|
|
|
|
t.Run("prompt user for a command", func(t *testing.T) {
|
2022-03-24 04:44:57 +00:00
|
|
|
cmd := commandctrl.NewCommandController(nil)
|
2022-03-24 01:54:32 +00:00
|
|
|
|
|
|
|
ctx, uiCtx := testuictx.New(context.Background())
|
|
|
|
err := cmd.Prompt().Execute(ctx)
|
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
promptMsg, ok := uiCtx.Messages[0].(events.PromptForInput)
|
|
|
|
assert.True(t, ok)
|
|
|
|
assert.Equal(t, ":", promptMsg.Prompt)
|
|
|
|
})
|
|
|
|
}
|