Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package producer_test |
||
2 | |||
3 | import ( |
||
4 | "net/http" |
||
5 | "testing" |
||
6 | |||
7 | "github.com/stefanoj3/dirstalk/pkg/scan" |
||
8 | "github.com/stefanoj3/dirstalk/pkg/scan/producer" |
||
9 | "github.com/stretchr/testify/assert" |
||
10 | ) |
||
11 | |||
12 | func TestDictionaryProducerShouldProduce(t *testing.T) { |
||
13 | t.Parallel() |
||
14 | |||
15 | const depth = 4 |
||
16 | |||
17 | sut := producer.NewDictionaryProducer( |
||
18 | []string{http.MethodGet, http.MethodPost}, |
||
19 | []string{"/home", "/about"}, |
||
20 | depth, |
||
21 | ) |
||
22 | |||
23 | results := make([]scan.Target, 0, 4) |
||
24 | |||
25 | producerChannel := sut.Produce() |
||
26 | for r := range producerChannel { |
||
27 | results = append(results, r) |
||
28 | } |
||
29 | |||
30 | assert.Len(t, results, 4) |
||
31 | |||
32 | expectedResults := []scan.Target{ |
||
33 | { |
||
34 | Depth: depth, |
||
35 | Path: "/home", |
||
36 | Method: http.MethodGet, |
||
37 | }, |
||
38 | { |
||
39 | Depth: depth, |
||
40 | Path: "/home", |
||
41 | Method: http.MethodPost, |
||
42 | }, |
||
43 | { |
||
44 | Depth: depth, |
||
45 | Path: "/about", |
||
46 | Method: http.MethodGet, |
||
47 | }, |
||
48 | { |
||
49 | Depth: depth, |
||
50 | Path: "/about", |
||
51 | Method: http.MethodPost, |
||
52 | }, |
||
53 | } |
||
54 | |||
55 | assert.Equal(t, expectedResults, results) |
||
56 | } |
||
57 |