Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cliui package #2411

Merged
merged 14 commits into from
May 5, 2022
26 changes: 17 additions & 9 deletions ignite/pkg/events/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,31 @@ func TestBusSend(t *testing.T) {
}{
{
name: "send status ongoing event",
bus: make(Bus),
bus: Bus{evchan: make(chan Event)},
ivanovpetr marked this conversation as resolved.
Show resolved Hide resolved
event: Event{
Status: StatusOngoing,
Description: "description",
},
},
{
name: "send status done event",
bus: make(Bus),
bus: Bus{evchan: make(chan Event)},
event: Event{
Status: StatusDone,
Description: "description",
},
},
{
name: "send status neutral event",
bus: Bus{evchan: make(chan Event)},
event: Event{
Status: StatusNeutral,
Description: "description",
},
},
{
name: "send event on nil bus",
bus: nil,
bus: Bus{},
event: Event{
Status: StatusDone,
Description: "description",
Expand All @@ -41,8 +49,8 @@ func TestBusSend(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
go tt.bus.Send(tt.event)
if tt.bus != nil {
require.Equal(t, tt.event, <-tt.bus)
if tt.bus.Events() != nil {
require.Equal(t, tt.event, <-tt.bus.Events())
}
tt.bus.Shutdown()
})
Expand All @@ -56,15 +64,15 @@ func TestBusShutdown(t *testing.T) {
}{
{
name: "shutdown nil bus",
bus: nil,
bus: Bus{},
},
{
name: "shutdown bus correctly",
bus: make(Bus),
bus: Bus{evchan: make(chan Event)},
},
{
name: "shutdown bus with size correctly",
bus: make(Bus, 1),
bus: Bus{evchan: make(chan Event, 1)},
},
}
for _, tt := range tests {
Expand Down Expand Up @@ -186,7 +194,7 @@ func TestNewBus(t *testing.T) {
defer bus.Shutdown()
for i := 0; i < 10; i++ {
go bus.Send(tt.event)
require.Equal(t, tt.event, <-bus)
require.Equal(t, tt.event, <-bus.Events())
}
})
}
Expand Down