@@ -153,6 +153,95 @@ func createTestTemplateData() generator.TemplateData {
153153 Language : "go" ,
154154 },
155155 },
156+ FilePaths : []string {"main.go" },
157+ }
158+ }
159+
160+ func createTreeOnlyTemplateData () generator.TemplateData {
161+ return generator.TemplateData {
162+ Structure : "test-project/\n ├── src/\n │ └── main.go\n └── README.md\n " ,
163+ Files : []generator.FileData {},
164+ FilePaths : []string {"src/main.go" , "README.md" },
165+ }
166+ }
167+
168+ func TestMarkdownFormatTreeOnly (t * testing.T ) {
169+ format := & MarkdownFormat {}
170+ data := createTreeOnlyTemplateData ()
171+
172+ content , tokens , err := format .Render (data )
173+ if err != nil {
174+ t .Fatalf ("Render failed: %v" , err )
175+ }
176+
177+ if ! strings .Contains (content , "# Project Structure" ) {
178+ t .Errorf ("Expected content to contain '# Project Structure'" )
179+ }
180+ if ! strings .Contains (content , "test-project/" ) {
181+ t .Errorf ("Expected content to contain 'test-project/'" )
182+ }
183+ if strings .Contains (content , "# Project Files" ) {
184+ t .Errorf ("Expected content to NOT contain '# Project Files' in tree-only mode" )
185+ }
186+ if tokens <= 0 {
187+ t .Errorf ("Expected tokens to be positive, got %d" , tokens )
188+ }
189+ }
190+
191+ func TestTxtFormatTreeOnly (t * testing.T ) {
192+ format := & TxtFormat {}
193+ data := createTreeOnlyTemplateData ()
194+
195+ content , tokens , err := format .Render (data )
196+ if err != nil {
197+ t .Fatalf ("Render failed: %v" , err )
198+ }
199+
200+ if ! strings .Contains (content , "PROJECT STRUCTURE" ) {
201+ t .Errorf ("Expected content to contain 'PROJECT STRUCTURE'" )
202+ }
203+ if ! strings .Contains (content , "test-project/" ) {
204+ t .Errorf ("Expected content to contain 'test-project/'" )
205+ }
206+ if strings .Contains (content , "PROJECT FILES" ) {
207+ t .Errorf ("Expected content to NOT contain 'PROJECT FILES' in tree-only mode" )
208+ }
209+ if tokens <= 0 {
210+ t .Errorf ("Expected tokens to be positive, got %d" , tokens )
211+ }
212+ }
213+
214+ func TestXMLFormatTreeOnly (t * testing.T ) {
215+ format := & XMLFormat {}
216+ data := createTreeOnlyTemplateData ()
217+
218+ content , tokens , err := format .Render (data )
219+ if err != nil {
220+ t .Fatalf ("Render failed: %v" , err )
221+ }
222+
223+ if ! strings .Contains (content , "<?xml" ) {
224+ t .Errorf ("Expected content to contain '<?xml'" )
225+ }
226+ if ! strings .Contains (content , "<project>" ) {
227+ t .Errorf ("Expected content to contain '<project>'" )
228+ }
229+ // Directory structure should be built from FilePaths
230+ if ! strings .Contains (content , "<directory name=\" src\" >" ) {
231+ t .Errorf ("Expected content to contain '<directory name=\" src\" >' from FilePaths" )
232+ }
233+ if ! strings .Contains (content , "<file name=\" main.go\" >" ) {
234+ t .Errorf ("Expected content to contain '<file name=\" main.go\" >' in filesystem section" )
235+ }
236+ if ! strings .Contains (content , "<file name=\" README.md\" >" ) {
237+ t .Errorf ("Expected content to contain '<file name=\" README.md\" >' in filesystem section" )
238+ }
239+ // Files section should be empty (no file contents)
240+ if strings .Contains (content , "<file path=" ) {
241+ t .Errorf ("Expected content to NOT contain file content elements in tree-only mode" )
242+ }
243+ if tokens <= 0 {
244+ t .Errorf ("Expected tokens to be positive, got %d" , tokens )
156245 }
157246}
158247
0 commit comments