From 45601bb6dcb42ecd7ccaa8d3e779f4e80620519c Mon Sep 17 00:00:00 2001 From: sowmiyamuthuraman <32141844+sowmiyamuthuraman@users.noreply.github.com> Date: Mon, 9 Sep 2019 23:40:17 +0530 Subject: [PATCH] Fix. Replace t.fatal() calls to testify assert/require calls (#12084) --- app/opengraph_test.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/app/opengraph_test.go b/app/opengraph_test.go index 867f02ea14..cd93fb7bca 100644 --- a/app/opengraph_test.go +++ b/app/opengraph_test.go @@ -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) } }) }