Skip to content

Commit f6c0899

Browse files
Implement tests of running of the handlers.ConcurrentHandler structure
1 parent af1f16d commit f6c0899

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

handlers/concurrent_handler_test.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,38 @@ func TestConcurrentHandler_running(test *testing.T) {
4040
links []crawler.SourcedLink
4141
runHandler func(ctx context.Context, handler ConcurrentHandler)
4242
}{
43-
// TODO: Add test cases.
43+
{
44+
name: "with the Run() method",
45+
links: []crawler.SourcedLink{
46+
{
47+
SourceLink: "http://example.com/",
48+
Link: "http://example.com/1",
49+
},
50+
{
51+
SourceLink: "http://example.com/",
52+
Link: "http://example.com/2",
53+
},
54+
},
55+
runHandler: func(ctx context.Context, handler ConcurrentHandler) {
56+
handler.Run(ctx)
57+
},
58+
},
59+
{
60+
name: "with the RunConcurrently() method",
61+
links: []crawler.SourcedLink{
62+
{
63+
SourceLink: "http://example.com/",
64+
Link: "http://example.com/1",
65+
},
66+
{
67+
SourceLink: "http://example.com/",
68+
Link: "http://example.com/2",
69+
},
70+
},
71+
runHandler: func(ctx context.Context, handler ConcurrentHandler) {
72+
handler.RunConcurrently(ctx, 10)
73+
},
74+
},
4475
} {
4576
test.Run(data.name, func(test *testing.T) {
4677
innerHandler := new(MockLinkHandler)

0 commit comments

Comments
 (0)