diff options
| author | Philipp Tanlak <philipp.tanlak@gmail.com> | 2025-01-10 12:49:32 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-10 12:49:32 +0100 |
| commit | bf99c233a18c3165e0d4d251b41224e5bc6eb93d (patch) | |
| tree | d32f0fd0770a049552cdd0d51e9402d594e9a35e /js_lib_test.go | |
| parent | 924184f37ef0d3e244f8e8991c259affb45d0ae2 (diff) | |
Implement nested scraping (#81)
Diffstat (limited to 'js_lib_test.go')
| -rw-r--r-- | js_lib_test.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/js_lib_test.go b/js_lib_test.go index aca8ce9..ad19380 100644 --- a/js_lib_test.go +++ b/js_lib_test.go @@ -8,6 +8,7 @@ import ( "encoding/json" "net/http" "os" + "sync/atomic" "testing" "github.com/philippta/flyscrape" @@ -203,10 +204,10 @@ func TestJSLibHTTPDownload(t *testing.T) { http.download("https://example.com/404.txt"); ` - nreqs := 0 + var nreqs atomic.Int32 client := &http.Client{ Transport: flyscrape.RoundTripFunc(func(r *http.Request) (*http.Response, error) { - nreqs++ + nreqs.Add(1) if r.URL.Path == "/content-disposition" { resp, err := flyscrape.MockResponse(200, "hello world") @@ -233,7 +234,7 @@ func TestJSLibHTTPDownload(t *testing.T) { wait() - require.Equal(t, nreqs, 8) + require.Equal(t, nreqs.Load(), int32(8)) require.FileExists(t, "foo.txt") require.FileExists(t, "dir/my-foo.txt") require.FileExists(t, "dir/bar.txt") |