Skip to content

Commit 42a1a96

Browse files
meenal06kegsay
andauthored
feat: implement all room_create tests (#157)
* feat: implement all room_create tests Signed-off-by: Meenal Trivedi <[email protected]> * fix Signed-off-by: Meenal Trivedi <[email protected]> * Update tests/apidoc_room_create_test.go Co-authored-by: kegsay <[email protected]> Co-authored-by: kegsay <[email protected]>
1 parent adae8c1 commit 42a1a96

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/apidoc_room_create_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,54 @@ func TestRoomCreate(t *testing.T) {
4646
},
4747
})
4848
})
49+
// sytest: POST /createRoom makes a room with a topic
50+
t.Run("POST /createRoom makes a room with a topic", func(t *testing.T) {
51+
t.Parallel()
52+
roomID := authedClient.CreateRoom(t, map[string]interface{}{
53+
"topic": "Test Room",
54+
"preset": "public_chat",
55+
})
56+
res := authedClient.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "state", "m.room.topic"})
57+
must.MatchResponse(t, res, match.HTTPResponse{
58+
JSON: []match.JSON{
59+
match.JSONKeyPresent("topic"),
60+
match.JSONKeyTypeEqual("topic", gjson.String),
61+
match.JSONKeyEqual("topic", "Test Room"),
62+
},
63+
})
64+
})
65+
// sytest: POST /createRoom makes a room with a name
66+
t.Run("POST /createRoom makes a room with a name", func(t *testing.T) {
67+
t.Parallel()
68+
roomID := authedClient.CreateRoom(t, map[string]interface{}{
69+
"name": "Test Room",
70+
"preset": "public_chat",
71+
})
72+
res := authedClient.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "state", "m.room.name"})
73+
must.MatchResponse(t, res, match.HTTPResponse{
74+
JSON: []match.JSON{
75+
match.JSONKeyPresent("name"),
76+
match.JSONKeyTypeEqual("name", gjson.String),
77+
match.JSONKeyEqual("name", "Test Room"),
78+
},
79+
})
80+
})
81+
// sytest: POST /createRoom creates a room with the given version
82+
t.Run("POST /createRoom creates a room with the given version", func(t *testing.T) {
83+
t.Parallel()
84+
roomID := authedClient.CreateRoom(t, map[string]interface{}{
85+
"room_version": "2",
86+
"preset": "public_chat",
87+
})
88+
res := authedClient.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "state", "m.room.create"})
89+
must.MatchResponse(t, res, match.HTTPResponse{
90+
JSON: []match.JSON{
91+
match.JSONKeyPresent("room_version"),
92+
match.JSONKeyTypeEqual("room_version", gjson.String),
93+
match.JSONKeyEqual("room_version", "2"),
94+
},
95+
})
96+
})
4997
// sytest: POST /createRoom makes a private room with invites
5098
t.Run("POST /createRoom makes a private room with invites", func(t *testing.T) {
5199
t.Parallel()

0 commit comments

Comments
 (0)