Skip to content

Commit 55c5a8c

Browse files
committed
Allow SendEventSynced to pass over prev_event querystring parameters
1 parent 15ba451 commit 55c5a8c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

internal/client/client.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,18 @@ func (c *CSAPI) SendEventSynced(t *testing.T, roomID string, e b.Event) string {
9393
if e.StateKey != nil {
9494
paths = []string{"_matrix", "client", "r0", "rooms", roomID, "state", e.Type, *e.StateKey}
9595
}
96-
res := c.MustDo(t, "PUT", paths, e.Content)
96+
97+
query := make(url.Values, len(e.PrevEvents))
98+
for _, prevEvent := range e.PrevEvents {
99+
query.Add("prev_event", prevEvent)
100+
}
101+
102+
b, err := json.Marshal(e.Content)
103+
if err != nil {
104+
t.Fatalf("CSAPI.Do failed to marshal JSON body: %s", err)
105+
}
106+
107+
res := c.MustDoRaw(t, "PUT", paths, b, "application/json", query)
97108
body := ParseJSON(t, res)
98109
eventID := GetJSONFieldStr(t, body, "event_id")
99110
t.Logf("SendEventSynced waiting for event ID %s", eventID)

internal/docker/deployment.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ type HomeserverDeployment struct {
3030
// will print container logs before killing the container.
3131
func (d *Deployment) Destroy(t *testing.T) {
3232
t.Helper()
33-
d.Deployer.Destroy(d, t.Failed())
33+
d.Deployer.Destroy(
34+
d,
35+
// TODO: Revert this back to `t.Failed()`.
36+
// I did this so I can always see the homersever logs regardless of outcome
37+
true,
38+
)
3439
}
3540

3641
// Client returns a CSAPI client targeting the given hsName, using the access token for the given userID.

0 commit comments

Comments
 (0)