Skip to content

Commit

Permalink
Add parser test
Browse files Browse the repository at this point in the history
  • Loading branch information
tygern committed May 1, 2024
1 parent e97a439 commit 0a1051d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pkg/feedsupport/parser_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package feedsupport_test

import (
"github.com/initialcapacity/ai-starter/pkg/feedsupport"
"github.com/initialcapacity/ai-starter/pkg/testsupport"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
)

func TestParser_AllLinks(t *testing.T) {
endpoint, server := testsupport.StartTestServer(t, func(mux *http.ServeMux) {
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte(`
<rss>
<channel>
<item><link>https://example.com/1</link></item>
<item><link>https://example.com/2</link></item>
</channel>
</rss>
`))
})
})
defer testsupport.StopTestServer(t, server)
parser := feedsupport.NewParser(http.Client{})

links, err := parser.AllLinks(endpoint)

assert.NoError(t, err)
assert.Equal(t, []string{"https://example.com/1", "https://example.com/2"}, links)
}

0 comments on commit 0a1051d

Please sign in to comment.