diff --git a/pkg/feedsupport/parser_test.go b/pkg/feedsupport/parser_test.go new file mode 100644 index 0000000..3357a08 --- /dev/null +++ b/pkg/feedsupport/parser_test.go @@ -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(` + + + https://example.com/1 + https://example.com/2 + + + `)) + }) + }) + 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) +}