Add test for Bridgy likes

pull/47/head
Jan-Lukas Else 2 months ago
parent b53b5f2b1b
commit c80adf4bf3

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0;url=https://example.com/@abc/109404425715413954#favorited-by-327512">
<title>Bridgy Response</title>
</head>
<article class="h-entry">
<span class="p-uid">tag:example.com,2013:109404425715413954_favorited_by_327512</span>
<span class="p-author h-card">
<data class="p-uid" value="tag:fosstodon.org,2013:jle"></data>
<data class="p-numeric-id" value="327512"></data>
<a class="p-name u-url" href="https://example.com/@jle">Jan-Lukas Else</a>
<span class="p-nickname">jle</span>
</span>
<a class="p-name u-url" href="https://example.com/@abc/109404425715413954#favorited-by-327512"></a>
<div class="">
</div>
<a class="u-like-of" href="https://example.com/@abc/109404425715413954"></a>
<a class="u-like-of" href="https://example.org/"></a>
<a class="u-like-of" href="https://example.org/notes/2022-11-25-yijsn"></a>
</article>
</html>

@ -87,6 +87,42 @@ func Test_verifyMentionBridgy(t *testing.T) {
require.Equal(t, "m4rk", m.Author)
}
func Test_verifyMastodonLikeBridgy(t *testing.T) {
testHtmlBytes, err := os.ReadFile("testdata/bridgymastodon.html")
require.NoError(t, err)
testHtml := string(testHtmlBytes)
mockClient := newFakeHttpClient()
mockClient.setFakeResponse(http.StatusOK, testHtml)
app := &goBlog{
httpClient: mockClient.Client,
cfg: createDefaultTestConfig(t),
d: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// do nothing
}),
}
app.cfg.Server.PublicAddress = "https://example.org"
_ = app.initConfig(false)
m := &mention{
Source: "https://example.com/@abc/109404425715413954#favorited-by-327512",
Target: "https://example.org/notes/2022-11-25-yijsn",
}
err = app.verifyMention(m)
require.NoError(t, err)
require.Equal(t, "https://example.org/notes/2022-11-25-yijsn", m.Target)
require.Equal(t, "https://example.com/@abc/109404425715413954#favorited-by-327512", m.Source)
require.Equal(t, "https://example.com/@abc/109404425715413954#favorited-by-327512", m.Url)
require.Equal(t, "Bridgy Response", m.Title)
require.Equal(t, "", m.Content)
require.Equal(t, "Jan-Lukas Else", m.Author)
}
func Test_verifyMentionColin(t *testing.T) {
testHtmlBytes, err := os.ReadFile("testdata/colin.html")

Loading…
Cancel
Save