@@ -26,48 +26,48 @@ import (
2626)
2727
2828func TestDirectoryPool_GetOrCreateSharedRepository (t * testing.T ) {
29- pool := & DirectoryPool {
29+ pool := & directoryPool {
3030 directories : sync.Map {},
3131 }
3232
3333 tempDir := t .TempDir ()
3434 repoDir := filepath .Join (tempDir , "test-repo" )
3535
3636 // First call should create new shared directory
37- shared1 , err := pool .GetOrCreateSharedRepository (repoDir , "test-repo" )
37+ shared1 , err := pool .getOrCreateSharedRepository (repoDir , "test-repo" )
3838 require .NoError (t , err )
3939 require .NotNil (t , shared1 )
4040 assert .Equal (t , 1 , shared1 .refCount )
4141
4242 // Second call should reuse existing directory
43- shared2 , err := pool .GetOrCreateSharedRepository (repoDir , "test-repo" )
43+ shared2 , err := pool .getOrCreateSharedRepository (repoDir , "test-repo" )
4444 require .NoError (t , err )
4545 assert .Same (t , shared1 , shared2 )
4646 assert .Equal (t , 2 , shared2 .refCount )
4747}
4848
4949func TestDirectoryPool_ReleaseSharedRepository (t * testing.T ) {
50- pool := & DirectoryPool {
50+ pool := & directoryPool {
5151 directories : sync.Map {},
5252 }
5353
5454 tempDir := t .TempDir ()
5555 repoDir := filepath .Join (tempDir , "test-repo" )
5656
5757 // Create shared repository
58- shared , err := pool .GetOrCreateSharedRepository (repoDir , "test-repo" )
58+ shared , err := pool .getOrCreateSharedRepository (repoDir , "test-repo" )
5959 require .NoError (t , err )
6060
6161 // Add another reference
62- _ , err = pool .GetOrCreateSharedRepository (repoDir , "test-repo" )
62+ _ , err = pool .getOrCreateSharedRepository (repoDir , "test-repo" )
6363 require .NoError (t , err )
6464
6565 // First release should decrement refCount
66- pool .ReleaseSharedRepository (repoDir , "test-repo" )
66+ pool .releaseSharedRepository (repoDir , "test-repo" )
6767 assert .Equal (t , 1 , shared .refCount )
6868
6969 // Second release should remove from pool and cleanup directory
70- pool .ReleaseSharedRepository (repoDir , "test-repo" )
70+ pool .releaseSharedRepository (repoDir , "test-repo" )
7171 _ , exists := pool .directories .Load (repoDir )
7272 assert .False (t , exists )
7373 _ , err = os .Stat (repoDir )
@@ -79,13 +79,13 @@ func TestSharedDirectory_WithLock(t *testing.T) {
7979 repo , err := initEmptyRepository (tempDir )
8080 require .NoError (t , err )
8181
82- shared := & SharedDirectory {
82+ shared := & sharedDirectory {
8383 repo : repo ,
8484 refCount : 1 ,
8585 }
8686
8787 called := false
88- err = shared .WithLock (func (r * git.Repository ) error {
88+ err = shared .withLock (func (r * git.Repository ) error {
8989 called = true
9090 assert .Same (t , repo , r )
9191 return nil
@@ -100,13 +100,13 @@ func TestSharedDirectory_WithRLock(t *testing.T) {
100100 repo , err := initEmptyRepository (tempDir )
101101 require .NoError (t , err )
102102
103- shared := & SharedDirectory {
103+ shared := & sharedDirectory {
104104 repo : repo ,
105105 refCount : 1 ,
106106 }
107107
108108 called := false
109- err = shared .WithRLock (func (r * git.Repository ) error {
109+ err = shared .withRLock (func (r * git.Repository ) error {
110110 called = true
111111 assert .Same (t , repo , r )
112112 return nil
@@ -117,7 +117,7 @@ func TestSharedDirectory_WithRLock(t *testing.T) {
117117}
118118
119119func TestDirectoryPool_ConcurrentAccess (t * testing.T ) {
120- pool := & DirectoryPool {
120+ pool := & directoryPool {
121121 directories : sync.Map {},
122122 }
123123
@@ -132,15 +132,15 @@ func TestDirectoryPool_ConcurrentAccess(t *testing.T) {
132132 wg .Add (1 )
133133 go func (id int ) {
134134 defer wg .Done ()
135- _ , err := pool .GetOrCreateSharedRepository (repoDir , "concurrent-repo" )
135+ _ , err := pool .getOrCreateSharedRepository (repoDir , "concurrent-repo" )
136136 assert .NoError (t , err )
137137 }(i )
138138 }
139139 wg .Wait ()
140140
141141 // Check final refCount
142142 sharedDir , _ := pool .directories .Load (repoDir )
143- shared := sharedDir .(* SharedDirectory )
143+ shared := sharedDir .(* sharedDirectory )
144144
145145 assert .Equal (t , numGoroutines , shared .refCount )
146146
@@ -149,7 +149,7 @@ func TestDirectoryPool_ConcurrentAccess(t *testing.T) {
149149 wg .Add (1 )
150150 go func () {
151151 defer wg .Done ()
152- pool .ReleaseSharedRepository (repoDir , "concurrent-repo" )
152+ pool .releaseSharedRepository (repoDir , "concurrent-repo" )
153153 }()
154154 }
155155 wg .Wait ()
@@ -160,7 +160,7 @@ func TestDirectoryPool_ConcurrentAccess(t *testing.T) {
160160}
161161
162162func TestDirectoryPool_InitEmptyRepositoryFailure (t * testing.T ) {
163- pool := & DirectoryPool {
163+ pool := & directoryPool {
164164 directories : sync.Map {},
165165 }
166166
@@ -174,7 +174,7 @@ func TestDirectoryPool_InitEmptyRepositoryFailure(t *testing.T) {
174174 repoDir := filepath .Join (filePath , "subdir" ) // This will fail because parent is a file
175175
176176 // Should fail to create repository
177- _ , err = pool .GetOrCreateSharedRepository (repoDir , "test-repo" )
177+ _ , err = pool .getOrCreateSharedRepository (repoDir , "test-repo" )
178178 assert .Error (t , err )
179179
180180 // Should not be in pool
@@ -183,12 +183,12 @@ func TestDirectoryPool_InitEmptyRepositoryFailure(t *testing.T) {
183183
184184 // Retry should work if we fix the issue
185185 os .Remove (filePath )
186- _ , err = pool .GetOrCreateSharedRepository (repoDir , "test-repo" )
186+ _ , err = pool .getOrCreateSharedRepository (repoDir , "test-repo" )
187187 assert .NoError (t , err )
188188}
189189
190190func TestDirectoryPool_OpenRepositoryFailure (t * testing.T ) {
191- pool := & DirectoryPool {
191+ pool := & directoryPool {
192192 directories : sync.Map {},
193193 }
194194
@@ -203,7 +203,7 @@ func TestDirectoryPool_OpenRepositoryFailure(t *testing.T) {
203203 require .NoError (t , err )
204204
205205 // Should fail to open corrupted repository
206- _ , err = pool .GetOrCreateSharedRepository (repoDir , "test-repo" )
206+ _ , err = pool .getOrCreateSharedRepository (repoDir , "test-repo" )
207207 assert .Error (t , err )
208208 assert .Contains (t , err .Error (), "corrupted cache was removed" )
209209
@@ -216,12 +216,12 @@ func TestDirectoryPool_OpenRepositoryFailure(t *testing.T) {
216216 assert .True (t , os .IsNotExist (err ))
217217
218218 // Retry should work now that corrupted dir is removed
219- _ , err = pool .GetOrCreateSharedRepository (repoDir , "test-repo" )
219+ _ , err = pool .getOrCreateSharedRepository (repoDir , "test-repo" )
220220 assert .NoError (t , err )
221221}
222222
223223func TestDirectoryPool_OpenRepositoryCleanupFailure (t * testing.T ) {
224- pool := & DirectoryPool {
224+ pool := & directoryPool {
225225 directories : sync.Map {},
226226 }
227227
@@ -242,7 +242,7 @@ func TestDirectoryPool_OpenRepositoryCleanupFailure(t *testing.T) {
242242 defer os .Chmod (repoDir , 0755 )
243243
244244 // Should fail to open and also fail to cleanup
245- _ , err = pool .GetOrCreateSharedRepository (repoDir , "test-repo" )
245+ _ , err = pool .getOrCreateSharedRepository (repoDir , "test-repo" )
246246 assert .Error (t , err )
247247 // When cleanup fails, error message should mention checking local cache
248248 assert .Contains (t , err .Error (), "check the local git cache" )
@@ -257,7 +257,7 @@ func TestDirectoryPool_OpenRepositoryCleanupFailure(t *testing.T) {
257257}
258258
259259func TestDirectoryPool_PathIsFile (t * testing.T ) {
260- pool := & DirectoryPool {
260+ pool := & directoryPool {
261261 directories : sync.Map {},
262262 }
263263
@@ -269,7 +269,7 @@ func TestDirectoryPool_PathIsFile(t *testing.T) {
269269 require .NoError (t , err )
270270
271271 // Should fail because path is a file, not a directory
272- _ , err = pool .GetOrCreateSharedRepository (filePath , "test-repo" )
272+ _ , err = pool .getOrCreateSharedRepository (filePath , "test-repo" )
273273 assert .Error (t , err )
274274 assert .Contains (t , err .Error (), "not a directory" )
275275
0 commit comments