Esempio n. 1
0
func TestCrawl(t *testing.T) {
	deets, err := pimports.Crawl("test/crawl-start.html")
	if err != nil {
		t.Fatal("Should not error during crawl", err)
	}

	l := len(deets)
	if l != 3 {
		t.Fatalf("Expected 3 details but got: %d", l)
	}

	if deets[0].Path != "test/crawl-start.html" {
		t.Error("Expected detail at 0 to be test/crawl-start.html")
	}

	if deets[1].Path != "test/middle/crawl-middle.html" {
		t.Error("Expected detail at 1 to be test/middle/crawl-middle.html")
	}

	if deets[2].Path != "test/crawl-end.html" {
		t.Error("Expected detail at 2 to be test/crawl-end.html")
	}
}
Esempio n. 2
0
func TestCrawlStopsOnError(t *testing.T) {
	_, err := pimports.Crawl("test/crawl-fail.html")
	if err == nil {
		t.Fatal("Expected failure to happen")
	}
}