@@ -91,50 +91,63 @@ func TestClientSpacesSummary(t *testing.T) {
9191 },
9292 })
9393
94+ // the API doesn't return event IDs so we need to key off the
95+ // 3-uple of room ID, event type and state key
96+ eventKey := func (srcRoomID , dstRoomID , evType string ) string {
97+ return srcRoomID + "|" + dstRoomID + "|" + evType
98+ }
99+
94100 // create the links
95- rootToR1 := alice .SendEventSynced (t , root , b.Event {
101+ rootToR1 := eventKey (root , r1 , spaceChildEventType )
102+ alice .SendEventSynced (t , root , b.Event {
96103 Type : spaceChildEventType ,
97104 StateKey : & r1 ,
98105 Content : map [string ]interface {}{
99106 "via" : []string {"hs1" },
100107 },
101108 })
102- rootToSS1 := alice .SendEventSynced (t , root , b.Event {
109+ rootToSS1 := eventKey (root , ss1 , spaceChildEventType )
110+ alice .SendEventSynced (t , root , b.Event {
103111 Type : spaceChildEventType ,
104112 StateKey : & ss1 ,
105113 Content : map [string ]interface {}{
106114 "via" : []string {"hs1" },
107115 },
108116 })
109- rootToR2 := alice .SendEventSynced (t , root , b.Event {
117+ rootToR2 := eventKey (root , r2 , spaceChildEventType )
118+ alice .SendEventSynced (t , root , b.Event {
110119 Type : spaceChildEventType ,
111120 StateKey : & r2 ,
112121 Content : map [string ]interface {}{
113122 "via" : []string {"hs1" },
114123 },
115124 })
116- r2ToRoot := alice .SendEventSynced (t , r2 , b.Event { // parent link
125+ r2ToRoot := eventKey (r2 , root , spaceParentEventType )
126+ alice .SendEventSynced (t , r2 , b.Event { // parent link
117127 Type : spaceParentEventType ,
118128 StateKey : & root ,
119129 Content : map [string ]interface {}{
120130 "via" : []string {"hs1" },
121131 },
122132 })
123- ss1ToSS2 := alice .SendEventSynced (t , ss1 , b.Event {
133+ ss1ToSS2 := eventKey (ss1 , ss2 , spaceChildEventType )
134+ alice .SendEventSynced (t , ss1 , b.Event {
124135 Type : spaceChildEventType ,
125136 StateKey : & ss2 ,
126137 Content : map [string ]interface {}{
127138 "via" : []string {"hs1" },
128139 },
129140 })
130- r3ToSS1 := alice .SendEventSynced (t , r3 , b.Event { // parent link only
141+ r3ToSS1 := eventKey (r3 , ss1 , spaceParentEventType )
142+ alice .SendEventSynced (t , r3 , b.Event { // parent link only
131143 Type : spaceParentEventType ,
132144 StateKey : & ss1 ,
133145 Content : map [string ]interface {}{
134146 "via" : []string {"hs1" },
135147 },
136148 })
137- ss2ToR4 := alice .SendEventSynced (t , ss2 , b.Event {
149+ ss2ToR4 := eventKey (ss2 , r4 , spaceChildEventType )
150+ alice .SendEventSynced (t , ss2 , b.Event {
138151 Type : spaceChildEventType ,
139152 StateKey : & r4 ,
140153 Content : map [string ]interface {}{
@@ -189,7 +202,7 @@ func TestClientSpacesSummary(t *testing.T) {
189202 ss1ToSS2 , r3ToSS1 ,
190203 ss2ToR4 ,
191204 }, func (r gjson.Result ) interface {} {
192- return r .Get ("event_id " ).Str
205+ return eventKey ( r .Get ("room_id " ).Str , r . Get ( "state_key" ). Str , r . Get ( "type" ). Str )
193206 }, nil ),
194207 },
195208 })
@@ -211,7 +224,7 @@ func TestClientSpacesSummary(t *testing.T) {
211224 }
212225 body := must .ParseJSON (t , res .Body )
213226 gjson .GetBytes (body , "events" ).ForEach (func (_ , val gjson.Result ) bool {
214- wantItems = must .CheckOff (t , wantItems , val .Get ("event_id " ).Str )
227+ wantItems = must .CheckOff (t , wantItems , eventKey ( val .Get ("room_id " ).Str , val . Get ( "state_key" ). Str , val . Get ( "type" ). Str ) )
215228 return true
216229 })
217230 if len (wantItems ) != 1 {
@@ -238,7 +251,7 @@ func TestClientSpacesSummary(t *testing.T) {
238251 rootToR1 , rootToR2 , rootToSS1 , r2ToRoot ,
239252 ss1ToSS2 , r3ToSS1 ,
240253 }, func (r gjson.Result ) interface {} {
241- return r .Get ("event_id " ).Str
254+ return eventKey ( r .Get ("room_id " ).Str , r . Get ( "state_key" ). Str , r . Get ( "type" ). Str )
242255 }, nil ),
243256 },
244257 })
@@ -262,7 +275,7 @@ func TestClientSpacesSummary(t *testing.T) {
262275 match .JSONCheckOff ("events" , []interface {}{
263276 rootToR1 , rootToR2 , r2ToRoot ,
264277 }, func (r gjson.Result ) interface {} {
265- return r .Get ("event_id " ).Str
278+ return eventKey ( r .Get ("room_id " ).Str , r . Get ( "state_key" ). Str , r . Get ( "type" ). Str )
266279 }, nil ),
267280 },
268281 })
0 commit comments