Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package dictionary_test |
||
2 | |||
3 | import ( |
||
4 | "bytes" |
||
5 | "testing" |
||
6 | |||
7 | "github.com/stefanoj3/dirstalk/pkg/dictionary" |
||
8 | "github.com/stretchr/testify/assert" |
||
9 | ) |
||
10 | |||
11 | func TestAbsolutePathsGenerator(t *testing.T) { |
||
12 | t.Parallel() |
||
13 | |||
14 | b := &bytes.Buffer{} |
||
15 | |||
16 | dictionaryGenerator := dictionary.NewGenerator(b) |
||
17 | |||
18 | err := dictionaryGenerator.GenerateDictionaryFrom( |
||
19 | "./testdata/directory_to_generate_dictionary", |
||
20 | true, |
||
21 | ) |
||
22 | assert.NoError(t, err) |
||
23 | |||
24 | expectedOutput := `testdata/directory_to_generate_dictionary/myfile.php |
||
25 | testdata/directory_to_generate_dictionary/subfolder/image.jpg |
||
26 | testdata/directory_to_generate_dictionary/subfolder/image2.gif |
||
27 | testdata/directory_to_generate_dictionary/subfolder/subsubfolder/myfile.php |
||
28 | testdata/directory_to_generate_dictionary/subfolder/subsubfolder/myfile2.php |
||
29 | ` |
||
30 | |||
31 | assert.Equal(t, expectedOutput, b.String()) |
||
32 | } |
||
33 | |||
34 | func TestFilenamePathsGenerator(t *testing.T) { |
||
35 | t.Parallel() |
||
36 | |||
37 | b := &bytes.Buffer{} |
||
38 | |||
39 | dictionaryGenerator := dictionary.NewGenerator(b) |
||
40 | |||
41 | err := dictionaryGenerator.GenerateDictionaryFrom( |
||
42 | "testdata/directory_to_generate_dictionary", |
||
43 | false, |
||
44 | ) |
||
45 | assert.NoError(t, err) |
||
46 | |||
47 | expectedOutput := `directory_to_generate_dictionary |
||
48 | myfile.php |
||
49 | subfolder |
||
50 | image.jpg |
||
51 | image2.gif |
||
52 | subsubfolder |
||
53 | myfile2.php |
||
54 | ` |
||
55 | |||
56 | assert.Equal(t, expectedOutput, b.String()) |
||
57 | } |
||
72 |