diff options
Diffstat (limited to 'cmd/crawl/crawl_test.go')
-rw-r--r-- | cmd/crawl/crawl_test.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/cmd/crawl/crawl_test.go b/cmd/crawl/crawl_test.go index 57acffc..1646e40 100644 --- a/cmd/crawl/crawl_test.go +++ b/cmd/crawl/crawl_test.go @@ -6,7 +6,6 @@ import ( "net/http" "net/http/httptest" "os" - "path/filepath" "testing" "git.jordan.im/crawl" @@ -25,6 +24,18 @@ func TestCrawl(t *testing.T) { } defer os.RemoveAll(tmpdir) + if err := os.Chdir(tmpdir); err != nil { + t.Fatal(err) + } + + // Create directory to (temporarily) store response bodies + if _, err := os.Stat("temp"); os.IsNotExist(err) { + err := os.Mkdir("temp", 0700) + if err != nil { + t.Fatal(err) + } + } + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case "/": @@ -46,7 +57,7 @@ func TestCrawl(t *testing.T) { crawl.NewSeedScope(seeds), ) - outf, err := os.Create(filepath.Join(tmpdir, "warc.gz")) + outf, err := os.Create("warc.gz") if err != nil { t.Fatal(err) } @@ -58,7 +69,7 @@ func TestCrawl(t *testing.T) { } crawler, err := crawl.NewCrawler( - filepath.Join(tmpdir, "db"), + "db", seeds, scope, crawl.FetcherFunc(fetch), |