@@ -29,7 +29,7 @@ func TestPrintProjectStructure(t *testing.T) {
2929 // Test text output
3030 t .Run ("TextOutput" , func (t * testing.T ) {
3131 output := captureOutput (func () {
32- PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "name" , "asc" , false )
32+ PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "name" , "asc" , false , - 1 )
3333 })
3434
3535 rootName := filepath .Base (tmpDir )
@@ -57,7 +57,7 @@ func TestPrintProjectStructure(t *testing.T) {
5757 // Test JSON output
5858 t .Run ("JSONOutput" , func (t * testing.T ) {
5959 output := captureOutput (func () {
60- PrintProjectStructure ("." , "" , "" , false , "json" , "blue" , "green" , "red" , []string {}, "name" , "asc" , false )
60+ PrintProjectStructure ("." , "" , "" , false , "json" , "blue" , "green" , "red" , []string {}, "name" , "asc" , false , - 1 )
6161 })
6262
6363 // Verify that the output is valid JSON
@@ -70,7 +70,7 @@ func TestPrintProjectStructure(t *testing.T) {
7070 // Test XML output
7171 t .Run ("XMLOutput" , func (t * testing.T ) {
7272 output := captureOutput (func () {
73- PrintProjectStructure ("." , "" , "" , false , "xml" , "blue" , "green" , "red" , []string {}, "name" , "asc" , false )
73+ PrintProjectStructure ("." , "" , "" , false , "xml" , "blue" , "green" , "red" , []string {}, "name" , "asc" , false , - 1 )
7474 })
7575
7676 // Verify that the output is valid XML
@@ -83,7 +83,7 @@ func TestPrintProjectStructure(t *testing.T) {
8383 // Test YAML output
8484 t .Run ("YAMLOutput" , func (t * testing.T ) {
8585 output := captureOutput (func () {
86- PrintProjectStructure ("." , "" , "" , false , "yaml" , "blue" , "green" , "red" , []string {}, "name" , "asc" , false )
86+ PrintProjectStructure ("." , "" , "" , false , "yaml" , "blue" , "green" , "red" , []string {}, "name" , "asc" , false , - 1 )
8787 })
8888
8989 // Verify that the output is valid YAML
@@ -96,7 +96,7 @@ func TestPrintProjectStructure(t *testing.T) {
9696 // Test exclusion patterns
9797 t .Run ("ExclusionPatterns" , func (t * testing.T ) {
9898 output := captureOutput (func () {
99- PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {"*.go" }, "name" , "asc" , false )
99+ PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {"*.go" }, "name" , "asc" , false , - 1 )
100100 })
101101
102102 rootName := filepath .Base (tmpDir )
@@ -120,7 +120,7 @@ func TestPrintProjectStructure(t *testing.T) {
120120 // Test sorting by name (ascending)
121121 t .Run ("SortByNameAsc" , func (t * testing.T ) {
122122 output := captureOutput (func () {
123- PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "name" , "asc" , false )
123+ PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "name" , "asc" , false , - 1 )
124124 })
125125
126126 // Verify that the output is sorted by name in ascending order
@@ -131,7 +131,7 @@ func TestPrintProjectStructure(t *testing.T) {
131131 // Test sorting by name (descending)
132132 t .Run ("SortByNameDesc" , func (t * testing.T ) {
133133 output := captureOutput (func () {
134- PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "name" , "desc" , false )
134+ PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "name" , "desc" , false , - 1 )
135135 })
136136
137137 // Verify that the output is sorted by name in descending order
@@ -142,7 +142,7 @@ func TestPrintProjectStructure(t *testing.T) {
142142 // Test sorting by size (ascending)
143143 t .Run ("SortBySizeAsc" , func (t * testing.T ) {
144144 output := captureOutput (func () {
145- PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "size" , "asc" , false )
145+ PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "size" , "asc" , false , - 1 )
146146 })
147147
148148 // Verify that the output is sorted by size in ascending order
@@ -153,7 +153,7 @@ func TestPrintProjectStructure(t *testing.T) {
153153 // Test sorting by size (descending)
154154 t .Run ("SortBySizeDesc" , func (t * testing.T ) {
155155 output := captureOutput (func () {
156- PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "size" , "desc" , false )
156+ PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "size" , "desc" , false , - 1 )
157157 })
158158
159159 // Verify that the output is sorted by size in descending order
@@ -164,7 +164,7 @@ func TestPrintProjectStructure(t *testing.T) {
164164 // Test sorting by time (ascending)
165165 t .Run ("SortByTimeAsc" , func (t * testing.T ) {
166166 output := captureOutput (func () {
167- PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "time" , "asc" , false )
167+ PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "time" , "asc" , false , - 1 )
168168 })
169169
170170 // Verify that the output is sorted by time in ascending order
@@ -175,7 +175,7 @@ func TestPrintProjectStructure(t *testing.T) {
175175 // Test sorting by time (descending)
176176 t .Run ("SortByTimeDesc" , func (t * testing.T ) {
177177 output := captureOutput (func () {
178- PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "time" , "desc" , false )
178+ PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "time" , "desc" , false , - 1 )
179179 })
180180
181181 // Verify that the output is sorted by time in descending order
@@ -186,13 +186,55 @@ func TestPrintProjectStructure(t *testing.T) {
186186 // Test including hidden files
187187 t .Run ("IncludeHidden" , func (t * testing.T ) {
188188 output := captureOutput (func () {
189- PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "name" , "asc" , true )
189+ PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "name" , "asc" , true , - 1 )
190190 })
191191
192192 // Verify that the output includes the hidden files
193193 // You can add specific checks based on your expected output
194194 t .Log (output )
195195 })
196+
197+ // Test maximum depth 0 (should only print the root directory)
198+ t .Run ("MaxDepthZero" , func (t * testing.T ) {
199+ output := captureOutput (func () {
200+ PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "name" , "asc" , false , 0 )
201+ })
202+
203+ rootName := filepath .Base (tmpDir )
204+ expected := rootName + "/\n " +
205+ "\n 0 directories, 0 files\n "
206+ output = strings .TrimSpace (output )
207+ expected = strings .TrimSpace (expected )
208+
209+ if output != expected {
210+ t .Errorf ("Unexpected output:\n Got:\n %s\n Expected:\n %s" , output , expected )
211+ }
212+ })
213+
214+ // Test maximum depth 2
215+ t .Run ("MaxDepthTwo" , func (t * testing.T ) {
216+ output := captureOutput (func () {
217+ PrintProjectStructure ("." , "" , "" , false , "text" , "blue" , "green" , "red" , []string {}, "name" , "asc" , false , 2 )
218+ })
219+
220+ rootName := filepath .Base (tmpDir )
221+
222+ expected := rootName + "/\n " +
223+ "├── cmd/\n " +
224+ "│ └── main.go\n " +
225+ "├── go.mod\n " +
226+ "├── internal/\n " +
227+ "│ └── utils/\n " +
228+ "└── pkg/\n " +
229+ " └── printer/\n " +
230+ "\n 5 directories, 2 files\n "
231+ output = strings .TrimSpace (output )
232+ expected = strings .TrimSpace (expected )
233+
234+ if output != expected {
235+ t .Errorf ("Unexpected output:\n Got:\n %s\n Expected:\n %s" , output , expected )
236+ }
237+ })
196238}
197239
198240// createTestProjectStructure creates a sample project structure for testing.
0 commit comments