test: remove flaky test

This commit is contained in:
Sale Djenic 2023-05-25 17:17:47 +02:00 committed by saledjenic
parent 34f5ef031c
commit 11408f92d7
1 changed files with 40 additions and 37 deletions

View File

@ -134,43 +134,46 @@ func TestStatusLinkPreviewData(t *testing.T) {
// require.Equal(t, statusSecurityAudit.ThumbnailURL, previewData.ThumbnailURL) // require.Equal(t, statusSecurityAudit.ThumbnailURL, previewData.ThumbnailURL)
// } // }
func TestTwitterLinkPreviewData(t *testing.T) { // Flaky test, gives the following error:
statusTweet1 := LinkPreviewData{ // Error: Received unexpected error: invalid character '<' looking for beginning of value
Site: "Twitter", //
Title: "Crypto isn't going anywhere.— Status (@ethstatus) July 26, 2021", // func TestTwitterLinkPreviewData(t *testing.T) {
} // statusTweet1 := LinkPreviewData{
statusTweet2 := LinkPreviewData{ // Site: "Twitter",
Site: "Twitter", // Title: "Crypto isn't going anywhere.— Status (@ethstatus) July 26, 2021",
Title: "🎉 Status v1.15 is a go! 🎉\n\n📌 Pin important messages in chats and groups" + // }
"\n✏ Edit messages after sending\n🔬 Scan QR codes with the browser\n⚡ FASTER app navigation!" + // statusTweet2 := LinkPreviewData{
"\nhttps://t.co/qKrhDArVKb— Status (@ethstatus) July 27, 2021", // Site: "Twitter",
} // Title: "🎉 Status v1.15 is a go! 🎉\n\n📌 Pin important messages in chats and groups" +
statusProfile := LinkPreviewData{ // "\n✏ Edit messages after sending\n🔬 Scan QR codes with the browser\n⚡ FASTER app navigation!" +
Site: "Twitter", // "\nhttps://t.co/qKrhDArVKb— Status (@ethstatus) July 27, 2021",
Title: "Tweets by ethstatus", // }
} // statusProfile := LinkPreviewData{
// Site: "Twitter",
// Title: "Tweets by ethstatus",
// }
ts := []struct { // ts := []struct {
URL string // URL string
Expected LinkPreviewData // Expected LinkPreviewData
ShouldFail bool // ShouldFail bool
}{ // }{
{"https://twitter.com/ethstatus/status/1419674733885407236", statusTweet1, false}, // {"https://twitter.com/ethstatus/status/1419674733885407236", statusTweet1, false},
{"https://twitter.com/ethstatus/status/1420035091997278214", statusTweet2, false}, // {"https://twitter.com/ethstatus/status/1420035091997278214", statusTweet2, false},
{"https://twitter.com/ethstatus", statusProfile, false}, // {"https://twitter.com/ethstatus", statusProfile, false},
{"https://www.test.com/unknown", LinkPreviewData{}, true}, // {"https://www.test.com/unknown", LinkPreviewData{}, true},
} // }
for _, u := range ts { // for _, u := range ts {
previewData, err := GetLinkPreviewData(u.URL) // previewData, err := GetLinkPreviewData(u.URL)
if u.ShouldFail { // if u.ShouldFail {
require.Error(t, err) // require.Error(t, err)
continue // continue
} // }
require.NoError(t, err) // require.NoError(t, err)
require.Equal(t, u.Expected.Site, previewData.Site) // require.Equal(t, u.Expected.Site, previewData.Site)
require.Equal(t, u.Expected.Title, previewData.Title) // require.Equal(t, u.Expected.Title, previewData.Title)
require.Equal(t, u.Expected.ThumbnailURL, previewData.ThumbnailURL) // require.Equal(t, u.Expected.ThumbnailURL, previewData.ThumbnailURL)
} // }
} // }