mirror of
https://github.com/matrix-org/dendrite
synced 2024-11-16 23:00:53 +01:00
Fix flakey stats tests
This commit is contained in:
parent
8c7b274e4e
commit
869bf4d0ac
1 changed files with 5 additions and 4 deletions
|
@ -8,6 +8,9 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
|
"github.com/matrix-org/util"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/internal/sqlutil"
|
"github.com/matrix-org/dendrite/internal/sqlutil"
|
||||||
"github.com/matrix-org/dendrite/setup/config"
|
"github.com/matrix-org/dendrite/setup/config"
|
||||||
"github.com/matrix-org/dendrite/test"
|
"github.com/matrix-org/dendrite/test"
|
||||||
|
@ -16,8 +19,6 @@ import (
|
||||||
"github.com/matrix-org/dendrite/userapi/storage/sqlite3"
|
"github.com/matrix-org/dendrite/userapi/storage/sqlite3"
|
||||||
"github.com/matrix-org/dendrite/userapi/storage/tables"
|
"github.com/matrix-org/dendrite/userapi/storage/tables"
|
||||||
"github.com/matrix-org/dendrite/userapi/types"
|
"github.com/matrix-org/dendrite/userapi/types"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
|
||||||
"github.com/matrix-org/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func mustMakeDBs(t *testing.T, dbType test.DBType) (
|
func mustMakeDBs(t *testing.T, dbType test.DBType) (
|
||||||
|
@ -227,7 +228,7 @@ func Test_UserStatistics(t *testing.T) {
|
||||||
mustUserUpdateRegistered(t, ctx, db, "user4", time.Now().AddDate(0, -2, 0))
|
mustUserUpdateRegistered(t, ctx, db, "user4", time.Now().AddDate(0, -2, 0))
|
||||||
mustUpdateDeviceLastSeen(t, ctx, db, "user4", time.Now())
|
mustUpdateDeviceLastSeen(t, ctx, db, "user4", time.Now())
|
||||||
startTime := time.Now().AddDate(0, 0, -2)
|
startTime := time.Now().AddDate(0, 0, -2)
|
||||||
err := statsDB.UpdateUserDailyVisits(ctx, nil, startTime, startTime.Truncate(time.Hour*24).Add(time.Hour))
|
err := statsDB.UpdateUserDailyVisits(ctx, nil, startTime, startTime.Truncate(time.Hour*24))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to update daily visits stats: %v", err)
|
t.Fatalf("unable to update daily visits stats: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -278,7 +279,7 @@ func Test_UserStatistics(t *testing.T) {
|
||||||
mustUpdateDeviceLastSeen(t, ctx, db, "user1", time.Now().AddDate(0, 0, -i))
|
mustUpdateDeviceLastSeen(t, ctx, db, "user1", time.Now().AddDate(0, 0, -i))
|
||||||
mustUpdateDeviceLastSeen(t, ctx, db, "user5", time.Now().AddDate(0, 0, -i))
|
mustUpdateDeviceLastSeen(t, ctx, db, "user5", time.Now().AddDate(0, 0, -i))
|
||||||
startTime := time.Now().AddDate(0, 0, -i)
|
startTime := time.Now().AddDate(0, 0, -i)
|
||||||
err := statsDB.UpdateUserDailyVisits(ctx, nil, startTime, startTime.Truncate(time.Hour*24).Add(time.Hour))
|
err := statsDB.UpdateUserDailyVisits(ctx, nil, startTime, startTime.Truncate(time.Hour*24))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to update daily visits stats: %v", err)
|
t.Fatalf("unable to update daily visits stats: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue