sqs-browse: started working on tests for controllers
This commit is contained in:
parent
fb749aaee2
commit
43680000a8
14 changed files with 305 additions and 39 deletions
|
|
@ -7,24 +7,25 @@ import (
|
|||
"github.com/lmika/awstools/internal/common/ui/uimodels"
|
||||
)
|
||||
|
||||
type dispatcherContext struct {
|
||||
d *Dispatcher
|
||||
type DispatcherContext struct {
|
||||
Publisher MessagePublisher
|
||||
}
|
||||
|
||||
func (dc dispatcherContext) Messagef(format string, args ...interface{}) {
|
||||
dc.d.publisher.Send(events.Message(fmt.Sprintf(format, args...)))
|
||||
func (dc DispatcherContext) Messagef(format string, args ...interface{}) {
|
||||
dc.Publisher.Send(events.Message(fmt.Sprintf(format, args...)))
|
||||
}
|
||||
|
||||
func (dc dispatcherContext) Send(teaMessage tea.Msg) {
|
||||
dc.d.publisher.Send(teaMessage)
|
||||
func (dc DispatcherContext) Send(teaMessage tea.Msg) {
|
||||
dc.Publisher.Send(teaMessage)
|
||||
}
|
||||
|
||||
func (dc dispatcherContext) Message(msg string) {
|
||||
dc.d.publisher.Send(events.Message(msg))
|
||||
func (dc DispatcherContext) Message(msg string) {
|
||||
dc.Publisher.Send(events.Message(msg))
|
||||
}
|
||||
|
||||
func (dc dispatcherContext) Input(prompt string, onDone uimodels.Operation) {
|
||||
dc.d.publisher.Send(events.PromptForInput{
|
||||
func (dc DispatcherContext) Input(prompt string, onDone uimodels.Operation) {
|
||||
dc.Publisher.Send(events.PromptForInput{
|
||||
Prompt: prompt,
|
||||
OnDone: onDone,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ func (d *Dispatcher) Start(ctx context.Context, operation uimodels.Operation) {
|
|||
|
||||
d.runningOp = operation
|
||||
go func() {
|
||||
subCtx := uimodels.WithContext(ctx, dispatcherContext{d})
|
||||
subCtx := uimodels.WithContext(ctx, DispatcherContext{d.publisher})
|
||||
|
||||
err := operation.Execute(subCtx)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -12,5 +12,6 @@ type Message string
|
|||
|
||||
// PromptForInput indicates that the context is requesting a line of input
|
||||
type PromptForInput struct {
|
||||
Prompt string
|
||||
OnDone uimodels.Operation
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue