Skip to content

Commit

Permalink
break downloader test
Browse files Browse the repository at this point in the history
  • Loading branch information
rusq committed Jan 3, 2025
1 parent 4309ce2 commit f8ba02c
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions downloader/downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package downloader
import (
"context"
"log/slog"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -51,7 +50,7 @@ func Test_fltSeen(t *testing.T) {
}
}()

dlqC := fltSeen(filesC)
dlqC := fltSeen(filesC, 4)

var got []Request
for f := range dlqC {
Expand All @@ -71,7 +70,7 @@ func BenchmarkFltSeen(b *testing.B) {
inputC <- req
}
}()
outputC := fltSeen(inputC)
outputC := fltSeen(inputC, 4)

for n := 0; n < b.N; n++ {
for out := range outputC {
Expand All @@ -92,7 +91,6 @@ func TestClient_Stop(t *testing.T) {
t.Run("already stopped", func(t *testing.T) {
c := &Client{
requests: make(chan Request),
wg: new(sync.WaitGroup),
options: options{lg: slog.Default()},
}
c.started.Store(true)
Expand All @@ -108,9 +106,7 @@ func TestClient_Download(t *testing.T) {
t.Run("not started", func(t *testing.T) {
c := &Client{
requests: make(chan Request),

wg: new(sync.WaitGroup),
options: options{lg: slog.Default()},
options: options{lg: slog.Default()},
}
err := c.Download("x/file", "http://example.com")
assert.Error(t, err, "expected error")
Expand All @@ -119,7 +115,6 @@ func TestClient_Download(t *testing.T) {
requests := make(chan Request, 1)
c := &Client{
requests: requests,
wg: new(sync.WaitGroup),
options: options{lg: slog.Default()},
}
c.started.Store(true)
Expand All @@ -141,25 +136,21 @@ func TestClient_startWorkers(t *testing.T) {
t.Parallel()
c := &Client{
requests: make(chan Request),
wg: new(sync.WaitGroup),
options: options{lg: slog.Default(), workers: 3},
}
defer close(c.requests)
c.startWorkers(context.Background())
assert.Equal(t, 3, c.options.workers)
assert.NotNil(t, c.wg)
})
t.Run("no workers specified", func(t *testing.T) {
t.Parallel()
c := &Client{
requests: make(chan Request),
wg: new(sync.WaitGroup),
options: options{lg: slog.Default()},
}
defer close(c.requests)
c.startWorkers(context.Background())
assert.Equal(t, defNumWorkers, c.options.workers)
assert.NotNil(t, c.wg)
})
}

Expand Down

0 comments on commit f8ba02c

Please sign in to comment.