Skip to content

Commit 29582e5

Browse files
committed
Some cleanup
1 parent 3611002 commit 29582e5

File tree

3 files changed

+8
-49
lines changed

3 files changed

+8
-49
lines changed

internal/docker/deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type HomeserverDeployment struct {
3131
// will print container logs before killing the container.
3232
func (d *Deployment) Destroy(t *testing.T) {
3333
t.Helper()
34-
d.Deployer.Destroy(d, true) // t.Failed()
34+
d.Deployer.Destroy(d, t.Failed())
3535
}
3636

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

internal/match/json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func jsonCheckOffInternal(wantKey string, wantItems []interface{}, allowUnwanted
126126
// it's an object).
127127
//
128128
// Usage: (ensures `events` has these events in any order, with the right event type)
129-
// JSONCheckOff("events", []interface{}{"$foo:bar", "$baz:quuz"}, func(r gjson.Result) interface{} {
129+
// JSONCheckOffAllowUnwanted("events", []interface{}{"$foo:bar", "$baz:quuz"}, func(r gjson.Result) interface{} {
130130
// return r.Get("event_id").Str
131131
// }, func(eventID interface{}, eventBody gjson.Result) error {
132132
// if eventBody.Get("type").Str != "m.room.message" {

tests/msc2716_test.go

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"github.com/matrix-org/complement/internal/client"
2222
"github.com/matrix-org/complement/internal/match"
2323
"github.com/matrix-org/complement/internal/must"
24-
"github.com/sirupsen/logrus"
2524
"github.com/tidwall/gjson"
2625
)
2726

@@ -53,7 +52,6 @@ var (
5352
func TestBackfillingHistory(t *testing.T) {
5453
deployment := Deploy(t, b.BlueprintHSWithApplicationService)
5554
defer deployment.Destroy(t)
56-
//defer time.Sleep(2 * time.Hour)
5755

5856
// Create the application service bridge user that is able to backfill messages
5957
asUserID := "@the-bridge-user:hs1"
@@ -96,8 +94,6 @@ func TestBackfillingHistory(t *testing.T) {
9694
// Register and join the virtual user
9795
ensureVirtualUserRegistered(t, as, virtualUserLocalpart)
9896

99-
// TODO: Try adding avatar and displayName and see if historical messages get this info
100-
10197
// Insert the most recent chunk of backfilled history
10298
backfillRes := backfillBatchHistoricalMessages(
10399
t,
@@ -147,15 +143,6 @@ func TestBackfillingHistory(t *testing.T) {
147143
// Since the original body can only be read once, create a new one from the body bytes we just read
148144
messagesRes.Body = ioutil.NopCloser(bytes.NewBuffer(messsageResBody))
149145

150-
// TODO: Remove, the context request is just for TARDIS visualizations
151-
contextRes := alice.MustDoFunc(t, "GET", []string{"_matrix", "client", "r0", "rooms", roomID, "context", eventsAfter[len(eventsAfter)-1]}, client.WithContentType("application/json"), client.WithQueries(url.Values{
152-
"limit": []string{"100"},
153-
}))
154-
contextResBody := client.ParseJSON(t, contextRes)
155-
logrus.WithFields(logrus.Fields{
156-
"contextResBody": string(contextResBody),
157-
}).Error("context res")
158-
159146
// Copy the array by value so we can modify it as we iterate in the foreach loop.
160147
// We save the full untouched `expectedMessageOrder` for use in the log messages
161148
workingExpectedMessageOrder := expectedMessageOrder
@@ -180,7 +167,7 @@ func TestBackfillingHistory(t *testing.T) {
180167
})
181168
})
182169

183-
t.Run("Backfilled historical events with MSC2716_HISTORICAL do not come down /sync", func(t *testing.T) {
170+
t.Run("Backfilled historical events with MSC2716_HISTORICAL do not come down in an incremental sync", func(t *testing.T) {
184171
t.Parallel()
185172

186173
roomID := as.CreateRoom(t, struct{}{})
@@ -226,39 +213,6 @@ func TestBackfillingHistory(t *testing.T) {
226213
})
227214
})
228215

229-
t.Run("Backfilled historical events without MSC2716_HISTORICAL come down /sync", func(t *testing.T) {
230-
t.Parallel()
231-
232-
roomID := as.CreateRoom(t, struct{}{})
233-
alice.JoinRoom(t, roomID, nil)
234-
235-
eventsBefore := createMessagesInRoom(t, alice, roomID, 1)
236-
eventBefore := eventsBefore[0]
237-
timeAfterEventBefore := time.Now()
238-
insertOriginServerTs := uint64(timeAfterEventBefore.UnixNano() / int64(time.Millisecond))
239-
240-
// Send an event that has `prev_event` and `ts` set but not `MSC2716_HISTORICAL`.
241-
// We should see these type of events in the `/sync` response
242-
eventWeShouldSee := sendEvent(t, as, "", roomID, event{
243-
Type: "m.room.message",
244-
PrevEvents: []string{
245-
eventBefore,
246-
},
247-
OriginServerTS: insertOriginServerTs,
248-
Content: map[string]interface{}{
249-
"msgtype": "m.text",
250-
"body": "Message with prev_event and ts but no MSC2716_HISTORICAL",
251-
// This is commented out on purpse.
252-
// We are explicitely testing when MSC2716_HISTORICAL isn't present
253-
//MSC2716_HISTORICAL: true,
254-
},
255-
})
256-
257-
alice.SyncUntilTimelineHas(t, roomID, func(r gjson.Result) bool {
258-
return r.Get("event_id").Str == eventWeShouldSee
259-
})
260-
})
261-
262216
t.Run("Unrecognised prev_event ID will throw an error", func(t *testing.T) {
263217
t.Parallel()
264218

@@ -306,6 +260,11 @@ func TestBackfillingHistory(t *testing.T) {
306260
)
307261
})
308262

263+
t.Run("TODO: Test if historical avatar/display name set back in time are picked up on historical messages", func(t *testing.T) {
264+
t.Skip("Skipping until implemented")
265+
// TODO: Try adding avatar and displayName and see if historical messages get this info
266+
})
267+
309268
t.Run("Historical messages are visible when joining on federated server", func(t *testing.T) {
310269
t.Skip("Skipping until federation is implemented")
311270
t.Parallel()

0 commit comments

Comments
 (0)