mirror of
https://github.com/tnypxl/rollup.git
synced 2025-12-16 07:23:17 +00:00
refactor: use wrapper functions for easier testing
This commit is contained in:
@@ -149,13 +149,13 @@ func scrapeURL(urlStr string, depth int, visited map[string]bool) (string, error
|
||||
|
||||
visited[urlStr] = true
|
||||
|
||||
content, err := extractAndConvertContent(urlStr)
|
||||
content, err := testExtractAndConvertContent(urlStr)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if depth > 0 {
|
||||
links, err := scraper.ExtractLinks(urlStr)
|
||||
links, err := testExtractLinks(urlStr)
|
||||
if err != nil {
|
||||
return content, fmt.Errorf("error extracting links: %v", err)
|
||||
}
|
||||
@@ -173,6 +173,9 @@ func scrapeURL(urlStr string, depth int, visited map[string]bool) (string, error
|
||||
return content, nil
|
||||
}
|
||||
|
||||
var testExtractAndConvertContent = extractAndConvertContent
|
||||
var testExtractLinks = scraper.ExtractLinks
|
||||
|
||||
func extractAndConvertContent(urlStr string) (string, error) {
|
||||
content, err := scraper.FetchWebpageContent(urlStr)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user