Replace t.fatal with testify package functions (#12842)
Этот коммит содержится в:
коммит произвёл
Ben Schumacher
родитель
3c06fc28ad
Коммит
d10c524d34
@@ -3,6 +3,8 @@ package web
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestRequireHookId(t *testing.T) {
|
||||
@@ -11,21 +13,14 @@ func TestRequireHookId(t *testing.T) {
|
||||
c.Params = &Params{HookId: "abcdefghijklmnopqrstuvwxyz"}
|
||||
c.RequireHookId()
|
||||
|
||||
if c.Err != nil {
|
||||
t.Fatal("Hook Id is Valid. Should not have set error in context")
|
||||
}
|
||||
require.Nil(t, c.Err, "Hook Id is Valid. Should not have set error in context")
|
||||
})
|
||||
|
||||
t.Run("WhenHookIdIsInvalid", func(t *testing.T) {
|
||||
c.Params = &Params{HookId: "abc"}
|
||||
c.RequireHookId()
|
||||
|
||||
if c.Err == nil {
|
||||
t.Fatal("Should have set Error in context")
|
||||
}
|
||||
|
||||
if c.Err.StatusCode != http.StatusBadRequest {
|
||||
t.Fatal("Should have set status as 400")
|
||||
}
|
||||
require.Error(t, c.Err, "Should have set Error in context")
|
||||
require.Equal(t, http.StatusBadRequest, c.Err.StatusCode, "Should have set status as 400")
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user