avoid t.Fatal() in tests (#9189)
I've been burned a few times by tests that simply fatal, requiring me to run another build to learn more about what the mismatch was. Avoid this. This is part of a long running goal of mine to make testing "better".
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
0bbabd137b
Коммит
d8c8a19d35
@@ -17,7 +17,7 @@ func TestAssignRole(t *testing.T) {
|
||||
CheckCommand(t, "roles", "system_admin", th.BasicUser.Email)
|
||||
|
||||
if result := <-th.App.Srv.Store.User().GetByEmail(th.BasicUser.Email); result.Err != nil {
|
||||
t.Fatal()
|
||||
t.Fatal(result.Err)
|
||||
} else {
|
||||
user := result.Data.(*model.User)
|
||||
if user.Roles != "system_user system_admin" {
|
||||
@@ -28,7 +28,7 @@ func TestAssignRole(t *testing.T) {
|
||||
CheckCommand(t, "roles", "member", th.BasicUser.Email)
|
||||
|
||||
if result := <-th.App.Srv.Store.User().GetByEmail(th.BasicUser.Email); result.Err != nil {
|
||||
t.Fatal()
|
||||
t.Fatal(result.Err)
|
||||
} else {
|
||||
user := result.Data.(*model.User)
|
||||
if user.Roles != "system_user" {
|
||||
|
||||
@@ -50,12 +50,10 @@ func TestCreateUserWithoutTeam(t *testing.T) {
|
||||
CheckCommand(t, "user", "create", "--email", email, "--password", "mypassword1", "--username", username)
|
||||
|
||||
if result := <-th.App.Srv.Store.User().GetByEmail(email); result.Err != nil {
|
||||
t.Fatal()
|
||||
t.Fatal(result.Err)
|
||||
} else {
|
||||
user := result.Data.(*model.User)
|
||||
if user.Email != email {
|
||||
t.Fatal()
|
||||
}
|
||||
require.Equal(t, email, user.Email)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +90,7 @@ func TestChangeUserEmail(t *testing.T) {
|
||||
t.Fatal("should've updated to the new email")
|
||||
}
|
||||
if result := <-th.App.Srv.Store.User().GetByEmail(newEmail); result.Err != nil {
|
||||
t.Fatal()
|
||||
t.Fatal(result.Err)
|
||||
} else {
|
||||
user := result.Data.(*model.User)
|
||||
if user.Email != newEmail {
|
||||
|
||||
Ссылка в новой задаче
Block a user