mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 15:03:09 -06:00
More tests
This commit is contained in:
parent
5f74a5cab7
commit
2bfd24e53f
|
|
@ -2184,7 +2184,8 @@ func TestGetMembership(t *testing.T) {
|
||||||
"access_token": accessToken,
|
"access_token": accessToken,
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
wantOK: true,
|
wantOK: true,
|
||||||
|
wantMemberCount: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "/joined_members - Alice leaves, shouldn't be able to see members ",
|
name: "/joined_members - Alice leaves, shouldn't be able to see members ",
|
||||||
|
|
@ -2201,6 +2202,22 @@ func TestGetMembership(t *testing.T) {
|
||||||
},
|
},
|
||||||
wantOK: false,
|
wantOK: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "/joined_members - Bob joins, Alice sees two members",
|
||||||
|
user: alice,
|
||||||
|
request: func(t *testing.T, room *test.Room, accessToken string) *http.Request {
|
||||||
|
return test.NewRequest(t, "GET", fmt.Sprintf("/_matrix/client/v3/rooms/%s/joined_members", room.ID), test.WithQueryParams(map[string]string{
|
||||||
|
"access_token": accessToken,
|
||||||
|
}))
|
||||||
|
},
|
||||||
|
additionalEvents: func(t *testing.T, room *test.Room) {
|
||||||
|
room.CreateAndInsert(t, bob, spec.MRoomMember, map[string]interface{}{
|
||||||
|
"membership": "join",
|
||||||
|
}, test.WithStateKey(bob.ID))
|
||||||
|
},
|
||||||
|
wantOK: true,
|
||||||
|
wantMemberCount: 2,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) {
|
test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) {
|
||||||
|
|
@ -2252,7 +2269,7 @@ func TestGetMembership(t *testing.T) {
|
||||||
|
|
||||||
// check we got the expected events
|
// check we got the expected events
|
||||||
if tc.wantOK {
|
if tc.wantOK {
|
||||||
memberCount := len(gjson.GetBytes(w.Body.Bytes(), "chunk").Array())
|
memberCount := len(gjson.GetBytes(w.Body.Bytes(), "joined").Map())
|
||||||
if memberCount != tc.wantMemberCount {
|
if memberCount != tc.wantMemberCount {
|
||||||
t.Fatalf("expected %d members, got %d", tc.wantMemberCount, memberCount)
|
t.Fatalf("expected %d members, got %d", tc.wantMemberCount, memberCount)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue