@@ -300,3 +300,58 @@ func TestSvnInit(t *testing.T) {
300300 t .Errorf ("Svn Init returns wrong version: %s" , v )
301301 }
302302}
303+
304+ func TestDetectRemoteFromInfoCommand (t * testing.T ) {
305+ tests := []struct {
306+ name string
307+ input string
308+ expected string
309+ hasError bool
310+ }{
311+ {
312+ name : "Unix line ending (LF)" ,
313+ input : "Path: /svn/repo\n URL: https://example.com/repo\n Repository Root: https://example.com\n " ,
314+ expected : "https://example.com/repo" ,
315+ hasError : false ,
316+ },
317+ {
318+ name : "Windows line ending (CRLF)" ,
319+ input : "Path: /svn/repo\r \n URL: https://example.com/repo\r \n Repository Root: https://example.com\r \n " ,
320+ expected : "https://example.com/repo" ,
321+ hasError : false ,
322+ },
323+ {
324+ name : "Old Mac line ending (CR)" ,
325+ input : "Path: /svn/repo\r URL: https://example.com/repo\r Repository Root: https://example.com\r " ,
326+ expected : "https://example.com/repo" ,
327+ hasError : false ,
328+ },
329+ {
330+ name : "URL not found" ,
331+ input : "Path: /svn/repo\n Repository Root: https://example.com\n " ,
332+ expected : "" ,
333+ hasError : true ,
334+ },
335+ {
336+ name : "URL with no line ending" ,
337+ input : "Path: /svn/repo\n URL: https://example.com/repo" ,
338+ expected : "" ,
339+ hasError : true ,
340+ },
341+ }
342+
343+ for _ , tt := range tests {
344+ t .Run (tt .name , func (t * testing.T ) {
345+ result , err := detectRemoteFromInfoCommand (tt .input )
346+ if tt .hasError && err == nil {
347+ t .Errorf ("expected error but got none" )
348+ }
349+ if ! tt .hasError && err != nil {
350+ t .Errorf ("unexpected error: %v" , err )
351+ }
352+ if result != tt .expected {
353+ t .Errorf ("expected %q, got %q" , tt .expected , result )
354+ }
355+ })
356+ }
357+ }
0 commit comments