MM-19463 - Migrate tests from "web/webhook_test.go" to use testify (#13524)
* MM-19463 - Migrate tests from "web/webhook_test.go" to use testify * fix shadows declaration * make test cleaner * fix wrong test order Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
Miguel de la Cruz
родитель
6e9e849871
Коммит
69f4dcd955
@@ -250,9 +250,7 @@ func TestCommandWebhooks(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hook, appErr := th.App.CreateCommandWebhook(cmd.Id, args)
|
hook, appErr := th.App.CreateCommandWebhook(cmd.Id, args)
|
||||||
if appErr != nil {
|
require.Nil(t, appErr)
|
||||||
t.Fatal(appErr)
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := http.Post(ApiClient.Url+"/hooks/commands/123123123123", "application/json", bytes.NewBufferString(`{"text":"this is a test"}`))
|
resp, err := http.Post(ApiClient.Url+"/hooks/commands/123123123123", "application/json", bytes.NewBufferString(`{"text":"this is a test"}`))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -263,12 +261,11 @@ func TestCommandWebhooks(t *testing.T) {
|
|||||||
assert.Equal(t, http.StatusBadRequest, resp.StatusCode)
|
assert.Equal(t, http.StatusBadRequest, resp.StatusCode)
|
||||||
|
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
if resp, appErr := http.Post(ApiClient.Url+"/hooks/commands/"+hook.Id, "application/json", bytes.NewBufferString(`{"text":"this is a test"}`)); err != nil || resp.StatusCode != http.StatusOK {
|
response, appErr2 := http.Post(ApiClient.Url+"/hooks/commands/"+hook.Id, "application/json", bytes.NewBufferString(`{"text":"this is a test"}`))
|
||||||
t.Fatal(appErr)
|
require.Nil(t, appErr2)
|
||||||
}
|
require.Equal(t, http.StatusOK, response.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp, _ := http.Post(ApiClient.Url+"/hooks/commands/"+hook.Id, "application/json", bytes.NewBufferString(`{"text":"this is a test"}`)); resp.StatusCode != http.StatusBadRequest {
|
resp, _ = http.Post(ApiClient.Url+"/hooks/commands/"+hook.Id, "application/json", bytes.NewBufferString(`{"text":"this is a test"}`))
|
||||||
t.Fatal("expected error for sixth usage")
|
require.Equal(t, http.StatusBadRequest, resp.StatusCode)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user