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