mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Fix. Replace t.fatal() calls to testify assert/require calls (#12084)
This commit is contained in:
committed by
Jesús Espino
parent
ec803ada0a
commit
45601bb6dc
@@ -4,6 +4,7 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -108,22 +109,17 @@ func TestMakeOpenGraphURLsAbsolute(t *testing.T) {
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
og := opengraph.NewOpenGraph()
|
||||
if err := og.ProcessHTML(strings.NewReader(tc.HTML)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err := og.ProcessHTML(strings.NewReader(tc.HTML))
|
||||
require.Nil(t, err)
|
||||
|
||||
makeOpenGraphURLsAbsolute(og, tc.RequestURL)
|
||||
|
||||
if og.URL != tc.URL {
|
||||
t.Fatalf("incorrect url, expected %v, got %v", tc.URL, og.URL)
|
||||
}
|
||||
assert.Equalf(t, og.URL, tc.URL, "incorrect url, expected %v, got %v", tc.URL, og.URL)
|
||||
|
||||
if len(og.Images) > 0 {
|
||||
if og.Images[0].URL != tc.ImageURL {
|
||||
t.Fatalf("incorrect image url, expected %v, got %v", tc.ImageURL, og.Images[0].URL)
|
||||
}
|
||||
} else if tc.ImageURL != "" {
|
||||
t.Fatalf("missing image url, expected %v, got nothing", tc.ImageURL)
|
||||
assert.Equalf(t, og.Images[0].URL, tc.ImageURL, "incorrect image url, expected %v, got %v", tc.ImageURL, og.Images[0].URL)
|
||||
} else {
|
||||
assert.Empty(t, tc.ImageURL, "missing image url, expected %v, got nothing", tc.ImageURL)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user