You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
GoBlog/microformats_test.go

38 lines
974 B

package main
import (
"net/http"
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_parseMicroformats(t *testing.T) {
app := &goBlog{
cfg: createDefaultTestConfig(t),
}
err := app.initConfig(false)
require.NoError(t, err)
testHtmlBytes, err := os.ReadFile("testdata/wmtest.html")
require.NoError(t, err)
testHtml := string(testHtmlBytes)
mockClient := newFakeHttpClient()
mockClient.setFakeResponse(http.StatusOK, testHtml)
app.httpClient = mockClient.Client
m, err := app.parseMicroformats("https://example.net/articles/micropub-crossposting-to-twitter-and-enabling-tweetstorms", false)
require.NoError(t, err)
assert.Equal(t, "Micropub, Crossposting to Twitter, and Enabling “Tweetsto…", m.Title)
assert.NotEmpty(t, m.Content)
assert.Equal(t, "Test Blogger", m.Author)
assert.Equal(t, "https://example.net/articles/micropub-crossposting-to-twitter-and-enabling-tweetstorms", m.Url)
}