@@ -24,10 +24,13 @@ func TestChasmNotifier_SubscribeAndNotify(t *testing.T) {
2424 notifier .Start ()
2525 defer notifier .Stop ()
2626
27- entityKey := chasm.EntityKey {
28- NamespaceID : tv .NamespaceID ().String (),
29- BusinessID : tv .WorkflowID (),
30- EntityID : tv .RunID (),
27+ componentKey := chasm.ComponentKey {
28+ EntityKey : chasm.EntityKey {
29+ NamespaceID : tv .NamespaceID ().String (),
30+ BusinessID : tv .WorkflowID (),
31+ EntityID : tv .RunID (),
32+ },
33+ Path : "" ,
3134 }
3235
3336 // Multiple subscribers
@@ -38,7 +41,7 @@ func TestChasmNotifier_SubscribeAndNotify(t *testing.T) {
3841 }, subscriberCount )
3942
4043 for i := range subscriberCount {
41- ch , id , err := notifier .Subscribe (entityKey )
44+ ch , id , err := notifier .Subscribe (componentKey )
4245 require .NoError (t , err )
4346 subscribers [i ].channel = ch
4447 subscribers [i ].id = id
@@ -47,7 +50,7 @@ func TestChasmNotifier_SubscribeAndNotify(t *testing.T) {
4750 // Single notification
4851 expectedRef := []byte ("test-ref" )
4952 notifier .Notify (& ChasmComponentNotification {
50- Key : entityKey ,
53+ Key : componentKey ,
5154 Ref : expectedRef ,
5255 })
5356
@@ -56,15 +59,15 @@ func TestChasmNotifier_SubscribeAndNotify(t *testing.T) {
5659 select {
5760 case received := <- sub .channel :
5861 require .NotNil (t , received , "subscriber %d" , i )
59- require .Equal (t , entityKey , received .Key , "subscriber %d" , i )
62+ require .Equal (t , componentKey , received .Key , "subscriber %d" , i )
6063 require .Equal (t , expectedRef , received .Ref , "subscriber %d" , i )
6164 case <- time .After (time .Second ):
6265 t .Fatalf ("subscriber %d: timeout waiting for notification" , i )
6366 }
6467 }
6568
6669 for _ , sub := range subscribers {
67- err := notifier .Unsubscribe (entityKey , sub .id )
70+ err := notifier .Unsubscribe (componentKey , sub .id )
6871 require .NoError (t , err )
6972 }
7073}
@@ -80,21 +83,24 @@ func TestChasmNotifier_KeyIsolation(t *testing.T) {
8083 notifier .Start ()
8184 defer notifier .Stop ()
8285
83- entityKey1 := chasm.EntityKey {
86+ entityKey := chasm.EntityKey {
8487 NamespaceID : tv .NamespaceID ().String (),
8588 BusinessID : tv .WorkflowID (),
8689 EntityID : tv .RunID (),
8790 }
88- entityKey2 := chasm.EntityKey {
89- NamespaceID : "different-namespace-id" ,
90- BusinessID : "different-workflow-id" ,
91- EntityID : "different-run-id" ,
91+ componentKey1 := chasm.ComponentKey {
92+ EntityKey : entityKey ,
93+ Path : "component1" ,
94+ }
95+ componentKey2 := chasm.ComponentKey {
96+ EntityKey : entityKey ,
97+ Path : "component2" ,
9298 }
9399
94- channel , subscriberID , err := notifier .Subscribe (entityKey1 )
100+ channel , subscriberID , err := notifier .Subscribe (componentKey1 )
95101 require .NoError (t , err )
96102 notifier .Notify (& ChasmComponentNotification {
97- Key : entityKey2 ,
103+ Key : componentKey2 ,
98104 Ref : []byte ("wrong-entity" ),
99105 })
100106 select {
@@ -103,7 +109,7 @@ func TestChasmNotifier_KeyIsolation(t *testing.T) {
103109 case <- time .After (50 * time .Millisecond ):
104110 }
105111
106- err = notifier .Unsubscribe (entityKey1 , subscriberID )
112+ err = notifier .Unsubscribe (componentKey1 , subscriberID )
107113 require .NoError (t , err )
108114}
109115
@@ -118,17 +124,20 @@ func TestChasmNotifier_UnsubscribeStopsDelivery(t *testing.T) {
118124 notifier .Start ()
119125 defer notifier .Stop ()
120126
121- entityKey := chasm.EntityKey {
122- NamespaceID : tv .NamespaceID ().String (),
123- BusinessID : tv .WorkflowID (),
124- EntityID : tv .RunID (),
127+ componentKey := chasm.ComponentKey {
128+ EntityKey : chasm.EntityKey {
129+ NamespaceID : tv .NamespaceID ().String (),
130+ BusinessID : tv .WorkflowID (),
131+ EntityID : tv .RunID (),
132+ },
133+ Path : "" ,
125134 }
126135
127136 // First notification should arrive
128- channel , subscriberID , err := notifier .Subscribe (entityKey )
137+ channel , subscriberID , err := notifier .Subscribe (componentKey )
129138 require .NoError (t , err )
130139 notifier .Notify (& ChasmComponentNotification {
131- Key : entityKey ,
140+ Key : componentKey ,
132141 Ref : []byte ("before-unsubscribe" ),
133142 })
134143 select {
@@ -139,10 +148,10 @@ func TestChasmNotifier_UnsubscribeStopsDelivery(t *testing.T) {
139148 }
140149
141150 // Notification after unsubscribe should not arrive
142- err = notifier .Unsubscribe (entityKey , subscriberID )
151+ err = notifier .Unsubscribe (componentKey , subscriberID )
143152 require .NoError (t , err )
144153 notifier .Notify (& ChasmComponentNotification {
145- Key : entityKey ,
154+ Key : componentKey ,
146155 Ref : []byte ("after-unsubscribe" ),
147156 })
148157 select {
0 commit comments