Update test to use testify framework (#12583)
* Update test to use testify framework * Add require.NotNil to avoid a nil err var * Add missing test var
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
b8dc5e3620
Коммит
40ff87637d
@@ -5,17 +5,17 @@ package model
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestCommandWebhookPreSave(t *testing.T) {
|
||||
h := CommandWebhook{}
|
||||
h.PreSave()
|
||||
if len(h.Id) != 26 {
|
||||
t.Fatal("Id should be generated")
|
||||
}
|
||||
if h.CreateAt == 0 {
|
||||
t.Fatal("CreateAt should be set")
|
||||
}
|
||||
|
||||
require.Len(t, h.Id, 26, "Id should be generated")
|
||||
require.NotEqual(t, 0, h.CreateAt, "CreateAt should be set")
|
||||
}
|
||||
|
||||
func TestCommandWebhookIsValid(t *testing.T) {
|
||||
@@ -44,11 +44,14 @@ func TestCommandWebhookIsValid(t *testing.T) {
|
||||
tmp := h
|
||||
test.Transform()
|
||||
err := h.IsValid()
|
||||
if test.ExpectedError == "" && err != nil {
|
||||
t.Fatal("hook should be valid")
|
||||
} else if test.ExpectedError != "" && test.ExpectedError != err.Id {
|
||||
t.Fatal("expected " + test.ExpectedError + " error")
|
||||
|
||||
if test.ExpectedError == "" {
|
||||
assert.Error(t, err, "hook should be valid")
|
||||
} else {
|
||||
require.NotNil(t, err)
|
||||
assert.Equal(t, test.ExpectedError, err.Id, "expected "+test.ExpectedError+" error")
|
||||
}
|
||||
|
||||
h = tmp
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user