Skip to content

Commit

Permalink
cleaned up broker test
Browse files Browse the repository at this point in the history
  • Loading branch information
lonelycode committed Aug 12, 2024
1 parent 203e150 commit 0459f84
Showing 1 changed file with 0 additions and 48 deletions.
48 changes: 0 additions & 48 deletions temporal/internal/driver/local/mockbroker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package local

import (
"context"
"sync"
"testing"
"time"
)
Expand Down Expand Up @@ -185,50 +184,3 @@ func TestMockMessage(t *testing.T) {
})
}
}

func TestMockBroker_Concurrency(t *testing.T) {
broker := NewMockBroker()
channels := []string{"channel1", "channel2", "channel3"}
messageCount := 100
subscriberCount := 5

var wg sync.WaitGroup
wg.Add(subscriberCount + 1) // +1 for the publisher

// Start subscribers
for i := 0; i < subscriberCount; i++ {
go func() {
defer wg.Done()
sub := broker.Subscribe(channels...)
defer sub.Close()

// Receive subscription confirmations
for range channels {
sub.Receive(context.Background())
}

// Receive messages
for j := 0; j < messageCount; j++ {
_, err := sub.Receive(context.Background())
if err != nil {
t.Errorf("Receive() error = %v", err)
}
}
}()
}

// Start publisher
go func() {
defer wg.Done()
for i := 0; i < messageCount; i++ {
for _, channel := range channels {
_, err := broker.Publish(channel, "test message")
if err != nil {
t.Errorf("Publish() error = %v", err)
}
}
}
}()

wg.Wait()
}

0 comments on commit 0459f84

Please sign in to comment.