@@ -51,7 +51,10 @@ type EventClient struct {
|
||||
|
||||
// Recv is a test implementation of Recv
|
||||
func (cli *EventClient) Recv() (*container.Event, error) {
|
||||
event := <-cli.Events
|
||||
event, ok := <-cli.Events
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("event channel closed")
|
||||
}
|
||||
return event, nil
|
||||
}
|
||||
|
||||
@@ -76,6 +79,18 @@ func NewFakeExecutionClient() *FakeExecutionClient {
|
||||
}
|
||||
}
|
||||
|
||||
// Stop the fake execution service. Needed when event is enabled.
|
||||
func (f *FakeExecutionClient) Stop() {
|
||||
if f.eventsQueue != nil {
|
||||
close(f.eventsQueue)
|
||||
}
|
||||
f.Lock()
|
||||
defer f.Unlock()
|
||||
for _, client := range f.eventClients {
|
||||
close(client.Events)
|
||||
}
|
||||
}
|
||||
|
||||
// WithEvents setup events publisher for FakeExecutionClient
|
||||
func (f *FakeExecutionClient) WithEvents() *FakeExecutionClient {
|
||||
f.eventsQueue = make(chan *container.Event, 1024)
|
||||
@@ -154,6 +169,13 @@ func (f *FakeExecutionClient) GetCalledNames() []string {
|
||||
return names
|
||||
}
|
||||
|
||||
// ClearCalls clear all call detail.
|
||||
func (f *FakeExecutionClient) ClearCalls() {
|
||||
f.Lock()
|
||||
defer f.Unlock()
|
||||
f.called = []CalledDetail{}
|
||||
}
|
||||
|
||||
// GetCalledDetails get detail of each call.
|
||||
func (f *FakeExecutionClient) GetCalledDetails() []CalledDetail {
|
||||
f.Lock()
|
||||
|
||||
Reference in New Issue
Block a user