(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func TestCrawlerPool_Use_UseOpt_Free(t *testing.T) { |
| 58 | scheduler.Init(4, 0) |
| 59 | pool := NewCrawlerPool(downloader.SurferDownloader) |
| 60 | pool.SetPipelineConfig("csv", 10) |
| 61 | pool.Reset(2) |
| 62 | |
| 63 | opt := pool.UseOpt() |
| 64 | if !opt.IsSome() { |
| 65 | t.Fatal("UseOpt returned None") |
| 66 | } |
| 67 | c := opt.Unwrap() |
| 68 | if c == nil { |
| 69 | t.Fatal("UseOpt returned nil crawler") |
| 70 | } |
| 71 | sp := &spider.Spider{ |
| 72 | Name: "TestSpider", |
| 73 | RuleTree: &spider.RuleTree{Trunk: map[string]*spider.Rule{}}, |
| 74 | Limit: -10, |
| 75 | } |
| 76 | c.Init(sp) |
| 77 | pool.Free(c) |
| 78 | |
| 79 | c2 := pool.Use() |
| 80 | if c2 == nil { |
| 81 | t.Fatal("Use returned nil") |
| 82 | } |
| 83 | pool.Free(c2) |
| 84 | } |
| 85 | |
| 86 | func TestCrawlerPool_UseOpt_returnsSome(t *testing.T) { |
| 87 | scheduler.Init(4, 0) |
nothing calls this directly
no test coverage detected