Merge from develop
This commit is contained in:
commit
d1f14120df
2 files changed
+30
-25
No files matched your search
@@ -71,31 +71,6 @@ func TestSimpleFetch(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestSimpleParse verifies that we can extract URLs (etc.) from a known document
|
||||
func TestSimpleParse(t *testing.T) {
|
||||
doc := `<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<img src="/assets/image.png"/>
|
||||
<a href="/about.html">
|
||||
</body>
|
||||
</html>`
|
||||
matches, err := parse(doc)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if len(matches) != 2 {
|
||||
t.Fatal("invalid number of matches in parse")
|
||||
}
|
||||
if matches[0] != "/about.html" {
|
||||
t.Error("match text is invalid")
|
||||
}
|
||||
if matches[1] != "/assets/image.png" {
|
||||
t.Error("match text is invalid")
|
||||
}
|
||||
}
|
||||
|
||||
// TestSimpleMap figures out the site map for the site in baseURL
|
||||
func TestSimpleMap(t *testing.T) {
|
||||
pages := docrawl(baseURL)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestSimpleParse verifies that we can extract URLs (etc.) from a known document
|
||||
func TestSimpleParse(t *testing.T) {
|
||||
doc := `<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<img src="/assets/image.png"/>
|
||||
<a href="/about.html">
|
||||
</body>
|
||||
</html>`
|
||||
matches, err := parse(doc)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if len(matches) != 2 {
|
||||
t.Error("invalid number of matches in parse")
|
||||
}
|
||||
if matches[0] != "/about.html" {
|
||||
t.Error("match text is invalid")
|
||||
}
|
||||
if matches[1] != "/assets/image.png" {
|
||||
t.Error("match text is invalid")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user