@@ -134,7 +134,8 @@ func TestBaseApp_CollectFromPaths(t *testing.T) {
134134 require .NoError (t , err )
135135
136136 t .Run ("collect from single file" , func (t * testing.T ) {
137- dotfiles , err := app .CollectFromPaths (ctx , "testapp" , []string {configFile })
137+ skipIgnored := true
138+ dotfiles , err := app .CollectFromPaths (ctx , "testapp" , []string {configFile }, & skipIgnored )
138139 require .NoError (t , err )
139140 assert .Len (t , dotfiles , 1 )
140141
@@ -148,7 +149,8 @@ func TestBaseApp_CollectFromPaths(t *testing.T) {
148149 })
149150
150151 t .Run ("collect from directory" , func (t * testing.T ) {
151- dotfiles , err := app .CollectFromPaths (ctx , "testapp" , []string {subDir })
152+ skipIgnored := true
153+ dotfiles , err := app .CollectFromPaths (ctx , "testapp" , []string {subDir }, & skipIgnored )
152154 require .NoError (t , err )
153155
154156 // Should find 2 files (hidden files are ignored)
@@ -169,17 +171,58 @@ func TestBaseApp_CollectFromPaths(t *testing.T) {
169171 })
170172
171173 t .Run ("collect from mixed paths" , func (t * testing.T ) {
172- dotfiles , err := app .CollectFromPaths (ctx , "testapp" , []string {configFile , subDir })
174+ skipIgnored := true
175+ dotfiles , err := app .CollectFromPaths (ctx , "testapp" , []string {configFile , subDir }, & skipIgnored )
173176 require .NoError (t , err )
174177 assert .Len (t , dotfiles , 3 ) // 1 file + 2 files from directory
175178 })
176179
177180 t .Run ("collect from non-existent path" , func (t * testing.T ) {
178181 nonExistentPath := filepath .Join (tmpDir , "does-not-exist" )
179- dotfiles , err := app .CollectFromPaths (ctx , "testapp" , []string {nonExistentPath })
182+ skipIgnored := true
183+ dotfiles , err := app .CollectFromPaths (ctx , "testapp" , []string {nonExistentPath }, & skipIgnored )
180184 require .NoError (t , err )
181185 assert .Empty (t , dotfiles ) // Should skip non-existent paths
182186 })
187+
188+ t .Run ("collect with ignored sections" , func (t * testing.T ) {
189+ // Create a file with ignored sections
190+ configWithIgnore := filepath .Join (tmpDir , "config_with_ignore.conf" )
191+ configContentWithIgnore := `line1
192+ # SHELLTIME IGNORE BEGIN
193+ secret_key=123456
194+ password=hidden
195+ # SHELLTIME IGNORE END
196+ line2
197+ visible_key=value`
198+ err = os .WriteFile (configWithIgnore , []byte (configContentWithIgnore ), 0644 )
199+ require .NoError (t , err )
200+
201+ // Test with skipIgnored = true (default behavior)
202+ skipIgnored := true
203+ dotfiles , err := app .CollectFromPaths (ctx , "testapp" , []string {configWithIgnore }, & skipIgnored )
204+ require .NoError (t , err )
205+ require .Len (t , dotfiles , 1 )
206+
207+ // Should not contain ignored sections
208+ assert .NotContains (t , dotfiles [0 ].Content , "secret_key" )
209+ assert .NotContains (t , dotfiles [0 ].Content , "password=hidden" )
210+ assert .NotContains (t , dotfiles [0 ].Content , "SHELLTIME IGNORE" )
211+ assert .Contains (t , dotfiles [0 ].Content , "line1" )
212+ assert .Contains (t , dotfiles [0 ].Content , "line2" )
213+ assert .Contains (t , dotfiles [0 ].Content , "visible_key=value" )
214+
215+ // Test with skipIgnored = false
216+ skipIgnored = false
217+ dotfiles , err = app .CollectFromPaths (ctx , "testapp" , []string {configWithIgnore }, & skipIgnored )
218+ require .NoError (t , err )
219+ require .Len (t , dotfiles , 1 )
220+
221+ // Should contain all content including ignored sections
222+ assert .Contains (t , dotfiles [0 ].Content , "secret_key" )
223+ assert .Contains (t , dotfiles [0 ].Content , "password=hidden" )
224+ assert .Contains (t , dotfiles [0 ].Content , "SHELLTIME IGNORE" )
225+ })
183226}
184227
185228func TestBaseApp_collectFromDirectory (t * testing.T ) {
@@ -524,7 +567,8 @@ func TestBaseApp_Integration(t *testing.T) {
524567
525568 t .Run ("full workflow" , func (t * testing.T ) {
526569 // 1. Collect dotfiles
527- dotfiles , err := app .CollectFromPaths (ctx , "testapp" , []string {configFile , subDir })
570+ skipIgnored := true
571+ dotfiles , err := app .CollectFromPaths (ctx , "testapp" , []string {configFile , subDir }, & skipIgnored )
528572 require .NoError (t , err )
529573 assert .Len (t , dotfiles , 2 )
530574
0 commit comments