0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-07-03 19:58:21 +02:00

Relax test a bit

This commit is contained in:
Till Faelligen 2022-10-14 10:37:04 +02:00
parent 088ad1dd21
commit fb44e33909
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E

View file

@ -192,19 +192,18 @@ func Test_Devices(t *testing.T) {
newName := "new display name" newName := "new display name"
err = db.UpdateDevice(ctx, localpart, deviceWithID.ID, &newName) err = db.UpdateDevice(ctx, localpart, deviceWithID.ID, &newName)
assert.NoError(t, err, "unable to update device displayname") assert.NoError(t, err, "unable to update device displayname")
updatedAfterTimestamp := time.Now().Unix()
err = db.UpdateDeviceLastSeen(ctx, localpart, deviceWithID.ID, "127.0.0.1", "Element Web") err = db.UpdateDeviceLastSeen(ctx, localpart, deviceWithID.ID, "127.0.0.1", "Element Web")
assert.NoError(t, err, "unable to update device last seen") assert.NoError(t, err, "unable to update device last seen")
deviceWithID.DisplayName = newName deviceWithID.DisplayName = newName
deviceWithID.LastSeenIP = "127.0.0.1" deviceWithID.LastSeenIP = "127.0.0.1"
deviceWithID.LastSeenTS = int64(gomatrixserverlib.AsTimestamp(time.Now().Truncate(time.Second)))
gotDevice, err = db.GetDeviceByID(ctx, localpart, deviceWithID.ID) gotDevice, err = db.GetDeviceByID(ctx, localpart, deviceWithID.ID)
assert.NoError(t, err, "unable to get device by id") assert.NoError(t, err, "unable to get device by id")
assert.Equal(t, 2, len(devices)) assert.Equal(t, 2, len(devices))
assert.Equal(t, deviceWithID.DisplayName, gotDevice.DisplayName) assert.Equal(t, deviceWithID.DisplayName, gotDevice.DisplayName)
assert.Equal(t, deviceWithID.LastSeenIP, gotDevice.LastSeenIP) assert.Equal(t, deviceWithID.LastSeenIP, gotDevice.LastSeenIP)
truncatedTime := gomatrixserverlib.Timestamp(gotDevice.LastSeenTS).Time().Truncate(time.Second) assert.Greater(t, gotDevice.LastSeenTS, updatedAfterTimestamp)
assert.Equal(t, gomatrixserverlib.Timestamp(deviceWithID.LastSeenTS), gomatrixserverlib.AsTimestamp(truncatedTime))
// create one more device and remove the devices step by step // create one more device and remove the devices step by step
newDeviceID := util.RandomString(16) newDeviceID := util.RandomString(16)