aboutsummaryrefslogtreecommitdiff
path: root/bus_test.go
diff options
context:
space:
mode:
author2026-03-22 16:13:20 +0300
committer2026-03-22 16:13:20 +0300
commit485f49c2323a95297c8b5ae5f44320825d66ae82 (patch)
tree3db739918a0a19387f8e85fb30cc7d2fcf31c669 /bus_test.go
parentv1.0.1 (diff)
downloadeventbus-1.1.0.tar.gz
eventbus-1.1.0.tar.bz2
eventbus-1.1.0.tar.xz
eventbus-1.1.0.zip
new versionHEADv1.1.0master
Diffstat (limited to '')
-rw-r--r--bus_test.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/bus_test.go b/bus_test.go
index d7d5a08..bfead50 100644
--- a/bus_test.go
+++ b/bus_test.go
@@ -15,12 +15,11 @@ func (e testEvent) Event() string {
return e.name
}
-func TestBusFire(t *testing.T) {
+func TestBusPublish(t *testing.T) {
bus := eventbus.New()
// Подписываемся на событие
- ch := bus.Subscribe("test.event")
- defer bus.Unsubscribe(ch)
+ ch := bus.Subscribe(t.Context(), "test.event")
// Создаем канал для проверки получения события
received := make(chan bool, 1)
@@ -38,7 +37,7 @@ func TestBusFire(t *testing.T) {
}()
// Отправляем событие
- bus.Fire(testEvent{name: "test.event"})
+ bus.Publish(testEvent{name: "test.event"})
// Проверяем получение события
select {
@@ -51,12 +50,12 @@ func TestBusFire(t *testing.T) {
}
}
-func TestBusFireWithWildcard(t *testing.T) {
+func TestBusPublishWithWildcard(t *testing.T) {
bus := eventbus.New(eventbus.NameSeparator("/"), eventbus.Wildcard("#"), eventbus.Capacity(32))
defer bus.Close()
// Подписываемся на wildcard событие
- ch := bus.Subscribe("/test/#")
+ ch := bus.Subscribe(t.Context(), "/test/#")
// Создаем канал для проверки получения события
received := make(chan bool, 1)
@@ -74,7 +73,7 @@ func TestBusFireWithWildcard(t *testing.T) {
}()
// Отправляем событие
- bus.Fire(testEvent{name: "/test/event"})
+ bus.Publish(testEvent{name: "/test/event"})
// Проверяем получение события
select {