PLT-5070: Server side component of Telemetry. (#5514)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ba028ed74b
Коммит
f182d196ff
@@ -1477,3 +1477,70 @@ func TestUserStoreSearch(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUserStoreAnalyticsGetInactiveUsersCount(t *testing.T) {
|
||||
Setup()
|
||||
|
||||
u1 := &model.User{}
|
||||
u1.Email = model.NewId()
|
||||
Must(store.User().Save(u1))
|
||||
|
||||
var count int64
|
||||
|
||||
if result := <-store.User().AnalyticsGetInactiveUsersCount(); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
} else {
|
||||
count = result.Data.(int64)
|
||||
}
|
||||
|
||||
u2 := &model.User{}
|
||||
u2.Email = model.NewId()
|
||||
u2.DeleteAt = model.GetMillis()
|
||||
Must(store.User().Save(u2))
|
||||
|
||||
if result := <-store.User().AnalyticsGetInactiveUsersCount(); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
} else {
|
||||
newCount := result.Data.(int64)
|
||||
if count != newCount-1 {
|
||||
t.Fatal("Expected 1 more inactive users but found otherwise.", count, newCount)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestUserStoreAnalyticsGetSystemAdminCount(t *testing.T) {
|
||||
Setup()
|
||||
|
||||
var countBefore int64
|
||||
if result := <-store.User().AnalyticsGetSystemAdminCount(); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
} else {
|
||||
countBefore = result.Data.(int64)
|
||||
}
|
||||
|
||||
u1 := model.User{}
|
||||
u1.Email = model.NewId()
|
||||
u1.Username = model.NewId()
|
||||
u1.Roles = "system_user system_admin"
|
||||
|
||||
u2 := model.User{}
|
||||
u2.Email = model.NewId()
|
||||
u2.Username = model.NewId()
|
||||
|
||||
if err := (<-store.User().Save(&u1)).Err; err != nil {
|
||||
t.Fatal("couldn't save user", err)
|
||||
}
|
||||
|
||||
if err := (<-store.User().Save(&u2)).Err; err != nil {
|
||||
t.Fatal("couldn't save user", err)
|
||||
}
|
||||
|
||||
if result := <-store.User().AnalyticsGetSystemAdminCount(); result.Err != nil {
|
||||
t.Fatal(result.Err)
|
||||
} else {
|
||||
// We expect to find 1 more system admin than there was at the start of this test function.
|
||||
if count := result.Data.(int64); count != countBefore+1 {
|
||||
t.Fatal("Did not get the expected number of system admins. Expected, got: ", countBefore+1, count)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user