MCPcopy Create free account
hub / github.com/VirusTotal/vt-cli / Test_NewFileDirReader

Function Test_NewFileDirReader

utils/file_utils_test.go:25–166  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func Test_NewFileDirReader(t *testing.T) {
26 t.Parallel()
27
28 useCases := []struct {
29 name string
30
31 directories []string
32 files []string
33 recursive bool
34 maxDepth int
35
36 want func(string) *StringArrayReader
37 }{
38
39 {
40 name: "want get back empty files",
41 directories: []string{},
42 files: []string{},
43 recursive: true,
44 maxDepth: 2,
45 want: func(d string) *StringArrayReader {
46 return &StringArrayReader{
47 strings: nil,
48 }
49 },
50 },
51 {
52 name: "want to read single file",
53 directories: []string{},
54 files: []string{"z.txt"},
55 recursive: true,
56 maxDepth: 2,
57 want: func(d string) *StringArrayReader {
58 return &StringArrayReader{
59 strings: []string{
60 filepath.Join(d, "z.txt"),
61 },
62 }
63 },
64 },
65 {
66 name: "want read all files within all subdirectories",
67 directories: []string{"sub", "sub/sub", ".hidden"},
68 files: []string{"a.txt", "b.txt", "sub/c.txt", "sub/sub/d.txt", ".hidden/config"},
69 recursive: true,
70 maxDepth: 3,
71 want: func(d string) *StringArrayReader {
72 return &StringArrayReader{
73 strings: []string{
74 filepath.Join(d, ".hidden/config"),
75 filepath.Join(d, "a.txt"),
76 filepath.Join(d, "b.txt"),
77 filepath.Join(d, "sub/c.txt"),
78 filepath.Join(d, "sub/sub/d.txt"),
79 },
80 }
81 },
82 },

Callers

nothing calls this directly

Calls 1

NewFileDirReaderFunction · 0.85

Tested by

no test coverage detected