Skip to content

Commit 667e187

Browse files
committed
use structs in channels
1 parent e1ff3ab commit 667e187

4 files changed

Lines changed: 18 additions & 18 deletions

File tree

backend/pkg/broker/topics/blcu/blcu_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ func TestBLCUTopic_Download_Push(t *testing.T) {
123123
}
124124

125125
// Use a timeout for client read
126-
done := make(chan bool)
126+
done := make(chan struct{})
127127
go func() {
128128
output, readErr := client.Read()
129129
if readErr != nil {
130130
logger.Error().Err(readErr).Msg("Client read failed")
131-
done <- true
131+
done <- struct{}{}
132132
return
133133
}
134134
if output.Topic != blcu.DownloadName {
@@ -137,7 +137,7 @@ func TestBLCUTopic_Download_Push(t *testing.T) {
137137
if string(output.Payload) != "test" {
138138
t.Error("Expected payload 'test', got", string(output.Payload))
139139
}
140-
done <- true
140+
done <- struct{}{}
141141
}()
142142

143143
select {
@@ -224,12 +224,12 @@ func TestBLCUTopic_Upload_Push(t *testing.T) {
224224
}
225225

226226
// Use a timeout for client read
227-
done := make(chan bool)
227+
done := make(chan struct{})
228228
go func() {
229229
output, err := client.Read()
230230
if err != nil {
231231
logger.Error().Err(err).Msg("Client read failed")
232-
done <- true
232+
done <- struct{}{}
233233
return
234234
}
235235
if output.Topic != blcu.UploadName {
@@ -238,7 +238,7 @@ func TestBLCUTopic_Upload_Push(t *testing.T) {
238238
if string(output.Payload) != "test" {
239239
t.Error("Expected payload 'test', got", string(output.Payload))
240240
}
241-
done <- true
241+
done <- struct{}{}
242242
}()
243243

244244
select {

backend/pkg/broker/topics/connection/connection_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ func TestConnectionTopic_Push(t *testing.T) {
7676
}
7777

7878
// Use a timeout for client read
79-
done := make(chan bool)
79+
done := make(chan struct{})
8080
go func() {
8181
output, readErr := client.Read()
8282
if readErr != nil {
8383
logger.Error().Err(readErr).Msg("Client read failed")
84-
done <- true
84+
done <- struct{}{}
8585
return
8686
}
8787
if output.Topic != data.UpdateName {
@@ -94,7 +94,7 @@ func TestConnectionTopic_Push(t *testing.T) {
9494
if string(output.Payload) != string(payloadBytes) {
9595
t.Error("Expected payload 'test', got", string(output.Payload))
9696
}
97-
done <- true
97+
done <- struct{}{}
9898
}()
9999

100100
select {
@@ -171,12 +171,12 @@ func TestConnectionTopic_ClientMessage(t *testing.T) {
171171
})
172172

173173
// Use a timeout for client read
174-
done := make(chan bool)
174+
done := make(chan struct{})
175175
go func() {
176176
output, readErr := client.Read()
177177
if readErr != nil {
178178
logger.Error().Err(readErr).Msg("Client read failed")
179-
done <- true
179+
done <- struct{}{}
180180
return
181181
}
182182
if output.Topic != data.SubscribeName {
@@ -190,7 +190,7 @@ func TestConnectionTopic_ClientMessage(t *testing.T) {
190190
comparison, _ := json.Marshal(payloadInput)
191191
t.Errorf("Expected payload %s , got %s", string(comparison), string(output.Payload))
192192
}
193-
done <- true
193+
done <- struct{}{}
194194
}()
195195

196196
select {

backend/pkg/broker/topics/data/data_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ func TestDataTopic_Push(t *testing.T) {
8989
}
9090

9191
// Use a timeout for client read
92-
done := make(chan bool)
92+
done := make(chan struct{})
9393
go func() {
9494
output, readErr := client.Read()
9595
if readErr != nil {
9696
logger.Error().Err(readErr).Msg("Client read failed")
97-
done <- true
97+
done <- struct{}{}
9898
return
9999
}
100100
if output.Topic != data.UpdateName {
@@ -118,7 +118,7 @@ func TestDataTopic_Push(t *testing.T) {
118118
if string(output.Payload) != string(payloadBytes) {
119119
t.Error("Expected payload 'test', got", string(output.Payload))
120120
}
121-
done <- true
121+
done <- struct{}{}
122122
}()
123123

124124
select {

backend/pkg/broker/topics/message/message_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ func TestMessageTopic_Push(t *testing.T) {
7878
}
7979

8080
// Use a timeout for client read
81-
done := make(chan bool)
81+
done := make(chan struct{})
8282
go func() {
8383
output, readErr := client.Read()
8484
if readErr != nil {
8585
logger.Error().Err(readErr).Msg("Client read failed")
86-
done <- true
86+
done <- struct{}{}
8787
return
8888
}
8989
if output.Topic != data.UpdateName {
@@ -97,7 +97,7 @@ func TestMessageTopic_Push(t *testing.T) {
9797
if string(output.Payload) != string(comparisonBytes) {
9898
t.Error("Expected payload 'test', got", string(output.Payload))
9999
}
100-
done <- true
100+
done <- struct{}{}
101101
}()
102102

103103
select {

0 commit comments

Comments
 (0)