aboutsummaryrefslogtreecommitdiff
path: root/userapi/storage/storage_test.go
diff options
context:
space:
mode:
authorTill Faelligen <2353100+S7evinK@users.noreply.github.com>2022-10-14 10:37:04 +0200
committerTill Faelligen <2353100+S7evinK@users.noreply.github.com>2022-10-14 10:37:04 +0200
commitfb44e33909660b5e37f2d422baf4ffa7ddc30b0a (patch)
tree00dade626546efb150fa9f9c7911ec301f3cc79c /userapi/storage/storage_test.go
parent088ad1dd21a06ad3c4ae2db2a73936ed3e0d809e (diff)
Relax test a bit
Diffstat (limited to 'userapi/storage/storage_test.go')
-rw-r--r--userapi/storage/storage_test.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/userapi/storage/storage_test.go b/userapi/storage/storage_test.go
index ca7c1bfd..1538a813 100644
--- a/userapi/storage/storage_test.go
+++ b/userapi/storage/storage_test.go
@@ -192,19 +192,18 @@ func Test_Devices(t *testing.T) {
newName := "new display name"
err = db.UpdateDevice(ctx, localpart, deviceWithID.ID, &newName)
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")
assert.NoError(t, err, "unable to update device last seen")
deviceWithID.DisplayName = newName
deviceWithID.LastSeenIP = "127.0.0.1"
- deviceWithID.LastSeenTS = int64(gomatrixserverlib.AsTimestamp(time.Now().Truncate(time.Second)))
gotDevice, err = db.GetDeviceByID(ctx, localpart, deviceWithID.ID)
assert.NoError(t, err, "unable to get device by id")
assert.Equal(t, 2, len(devices))
assert.Equal(t, deviceWithID.DisplayName, gotDevice.DisplayName)
assert.Equal(t, deviceWithID.LastSeenIP, gotDevice.LastSeenIP)
- truncatedTime := gomatrixserverlib.Timestamp(gotDevice.LastSeenTS).Time().Truncate(time.Second)
- assert.Equal(t, gomatrixserverlib.Timestamp(deviceWithID.LastSeenTS), gomatrixserverlib.AsTimestamp(truncatedTime))
+ assert.Greater(t, gotDevice.LastSeenTS, updatedAfterTimestamp)
// create one more device and remove the devices step by step
newDeviceID := util.RandomString(16)