Live video on the AT Protocol
79
fork

Configure Feed

Select the types of activity you want to include in your feed.

at natb/command-errors 28 lines 668 B view raw
1package misttriggers 2 3import ( 4 "context" 5 "fmt" 6 "sync" 7 "testing" 8 9 "github.com/stretchr/testify/require" 10) 11 12func TestItCallsFunctions(t *testing.T) { 13 broker := NewTriggerBroker() 14 mu := sync.Mutex{} 15 calls := 0 16 increment := func(ctx context.Context, payload *StreamBufferPayload) error { 17 require.Equal(t, payload.StreamName, "TestStream") 18 mu.Lock() 19 defer mu.Unlock() 20 calls += 1 21 return fmt.Errorf("something went wrong") 22 } 23 broker.OnStreamBuffer(increment) 24 broker.OnStreamBuffer(increment) 25 broker.OnStreamBuffer(increment) 26 broker.TriggerStreamBuffer(context.Background(), &StreamBufferPayload{StreamName: "TestStream"}) 27 require.Equal(t, calls, 3) 28}