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
@@ -5,25 +5,20 @@ package model
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestCompliancePostHeader(t *testing.T) {
|
||||
if CompliancePostHeader()[0] != "TeamName" {
|
||||
t.Fatal()
|
||||
}
|
||||
require.Equal(t, "TeamName", CompliancePostHeader()[0])
|
||||
}
|
||||
|
||||
func TestCompliancePost(t *testing.T) {
|
||||
o := CompliancePost{TeamName: "test", PostFileIds: "files", PostCreateAt: GetMillis()}
|
||||
r := o.Row()
|
||||
|
||||
if r[0] != "test" {
|
||||
t.Fatal()
|
||||
}
|
||||
|
||||
if r[len(r)-1] != "files" {
|
||||
t.Fatal()
|
||||
}
|
||||
require.Equal(t, "test", r[0])
|
||||
require.Equal(t, "files", r[len(r)-1])
|
||||
}
|
||||
|
||||
var cleanTests = []struct {
|
||||
|
||||
Ссылка в новой задаче
Block a user