|
355 | 355 | (should (equal "https://us-west-2.console.aws.amazon.com/codesuite/codecommit/repositories/repo/browse" |
356 | 356 | (git-link-homepage-codecommit "https://us-west-2.console.aws.amazon.com" "codesuite/codecommit/repositories/repo")))) |
357 | 357 |
|
| 358 | +(ert-deftest git-link-interactive-simulation () |
| 359 | + "Test interactive git-link function call with cursor at line 3 using real git repo." |
| 360 | + (let ((test-dir (make-temp-file "git-link-test" t))) |
| 361 | + (unwind-protect |
| 362 | + (let ((default-directory test-dir) |
| 363 | + git-link-add-to-kill-ring ; Don't add to kill ring during test |
| 364 | + git-link-open-in-browser) ; Don't open browser during test |
| 365 | + |
| 366 | + ;; Set up a real git repository |
| 367 | + (shell-command "git init") |
| 368 | + (shell-command "git config user.name 'Test User'") |
| 369 | + (shell-command "git config user.email 'test@example.com'") |
| 370 | + (shell-command "git remote add origin https://github.com/user/repo.git") |
| 371 | + |
| 372 | + ;; Create test file with content |
| 373 | + (with-temp-file (expand-file-name "test-file.txt" test-dir) |
| 374 | + (insert "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\n")) |
| 375 | + |
| 376 | + ;; Add and commit the file |
| 377 | + (shell-command "git add test-file.txt") |
| 378 | + (shell-command "git commit -m 'Initial commit'") |
| 379 | + |
| 380 | + ;; Create a buffer visiting the file and position cursor at line 3 |
| 381 | + (with-current-buffer (find-file-noselect (expand-file-name "test-file.txt" test-dir)) |
| 382 | + (goto-char (point-min)) |
| 383 | + (forward-line 2) ; Move to line 3 |
| 384 | + |
| 385 | + ;; Call git-link interactively |
| 386 | + (let ((result (git-link "origin" 3 nil))) ; Line 3, no end line |
| 387 | + ;; Verify the result is the complete expected URL |
| 388 | + (should (equal "https://github.com/user/repo/blob/master/test-file.txt#L3" result))) |
| 389 | + |
| 390 | + ;; Clean up buffer |
| 391 | + (kill-buffer))) |
| 392 | + |
| 393 | + ;; Clean up temporary directory |
| 394 | + (when (file-exists-p test-dir) |
| 395 | + (delete-directory test-dir t))))) |
| 396 | + |
358 | 397 |
|
0 commit comments