2022-03-24 01:54:32 +00:00
|
|
|
package commandctrl_test
|
|
|
|
|
|
|
|
import (
|
2023-01-26 10:46:31 +00:00
|
|
|
"context"
|
2022-08-18 11:39:13 +00:00
|
|
|
"github.com/lmika/audax/internal/common/ui/events"
|
2023-01-26 10:46:31 +00:00
|
|
|
"github.com/lmika/audax/internal/dynamo-browse/services"
|
2022-03-24 21:17:52 +00:00
|
|
|
"testing"
|
|
|
|
|
2022-07-28 11:36:16 +00:00
|
|
|
"github.com/lmika/audax/internal/common/ui/commandctrl"
|
2022-03-24 01:54:32 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCommandController_Prompt(t *testing.T) {
|
|
|
|
t.Run("prompt user for a command", func(t *testing.T) {
|
2023-01-26 10:46:31 +00:00
|
|
|
cmd := commandctrl.NewCommandController(mockIterProvider{})
|
2022-03-24 01:54:32 +00:00
|
|
|
|
2022-08-18 11:39:13 +00:00
|
|
|
res := cmd.Prompt()
|
2022-03-24 01:54:32 +00:00
|
|
|
|
2022-03-28 20:48:09 +00:00
|
|
|
promptForInputMsg, ok := res.(events.PromptForInputMsg)
|
2022-03-24 01:54:32 +00:00
|
|
|
assert.True(t, ok)
|
2022-03-28 20:48:09 +00:00
|
|
|
assert.Equal(t, ":", promptForInputMsg.Prompt)
|
2022-03-24 01:54:32 +00:00
|
|
|
})
|
|
|
|
}
|
2023-01-26 10:46:31 +00:00
|
|
|
|
|
|
|
type mockIterProvider struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m mockIterProvider) Iter(ctx context.Context, category string) services.HistoryProvider {
|
|
|
|
return nil
|
|
|
|
}
|