diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-custom-buffer-file-clear-to-bottom-of-buffer.el (renamed from tests/test-custom-file-buffer-clear-to-bottom-of-buffer.el) | 10 | ||||
| -rw-r--r-- | tests/test-custom-buffer-file-clear-to-top-of-buffer.el (renamed from tests/test-custom-file-buffer-clear-to-top-of-buffer.el) | 10 | ||||
| -rw-r--r-- | tests/test-custom-buffer-file-copy-link-to-buffer-file.el (renamed from tests/test-custom-file-buffer-copy-link-to-buffer-file.el) | 10 | ||||
| -rw-r--r-- | tests/test-custom-buffer-file-copy-path-to-buffer-file-as-kill.el (renamed from tests/test-custom-file-buffer-copy-path-to-buffer-file-as-kill.el) | 10 | ||||
| -rw-r--r-- | tests/test-custom-buffer-file-copy-whole-buffer.el (renamed from tests/test-custom-file-buffer-copy-whole-buffer.el) | 10 | ||||
| -rw-r--r-- | tests/test-custom-buffer-file-delete-buffer-and-file.el (renamed from tests/test-custom-file-buffer-delete-buffer-and-file.el) | 10 | ||||
| -rw-r--r-- | tests/test-custom-buffer-file-move-buffer-and-file.el (renamed from tests/test-custom-file-buffer-move-buffer-and-file.el) | 10 | ||||
| -rw-r--r-- | tests/test-custom-buffer-file-rename-buffer-and-file.el (renamed from tests/test-custom-file-buffer-rename-buffer-and-file.el) | 10 | ||||
| -rw-r--r-- | tests/test-org-gcal-mock.el | 112 |
9 files changed, 152 insertions, 40 deletions
diff --git a/tests/test-custom-file-buffer-clear-to-bottom-of-buffer.el b/tests/test-custom-buffer-file-clear-to-bottom-of-buffer.el index 969f9bb7..bd309880 100644 --- a/tests/test-custom-file-buffer-clear-to-bottom-of-buffer.el +++ b/tests/test-custom-buffer-file-clear-to-bottom-of-buffer.el @@ -1,7 +1,7 @@ -;;; test-custom-file-buffer-clear-to-bottom-of-buffer.el --- Tests for cj/clear-to-bottom-of-buffer -*- lexical-binding: t; -*- +;;; test-custom-buffer-file-clear-to-bottom-of-buffer.el --- Tests for cj/clear-to-bottom-of-buffer -*- lexical-binding: t; -*- ;;; Commentary: -;; Tests for the cj/clear-to-bottom-of-buffer function from custom-file-buffer.el +;; Tests for the cj/clear-to-bottom-of-buffer function from custom-buffer-file.el ;; ;; This function deletes all text from point to the end of the current buffer. ;; It does not save the deleted text in the kill ring. @@ -22,7 +22,7 @@ (provide 'ps-print) ;; Now load the actual production module -(require 'custom-file-buffer) +(require 'custom-buffer-file) ;;; Setup and Teardown @@ -159,5 +159,5 @@ (should-error (cj/clear-to-bottom-of-buffer))) (test-clear-to-bottom-teardown))) -(provide 'test-custom-file-buffer-clear-to-bottom-of-buffer) -;;; test-custom-file-buffer-clear-to-bottom-of-buffer.el ends here +(provide 'test-custom-buffer-file-clear-to-bottom-of-buffer) +;;; test-custom-buffer-file-clear-to-bottom-of-buffer.el ends here diff --git a/tests/test-custom-file-buffer-clear-to-top-of-buffer.el b/tests/test-custom-buffer-file-clear-to-top-of-buffer.el index 18e3f71b..2bf79b27 100644 --- a/tests/test-custom-file-buffer-clear-to-top-of-buffer.el +++ b/tests/test-custom-buffer-file-clear-to-top-of-buffer.el @@ -1,7 +1,7 @@ -;;; test-custom-file-buffer-clear-to-top-of-buffer.el --- Tests for cj/clear-to-top-of-buffer -*- lexical-binding: t; -*- +;;; test-custom-buffer-file-clear-to-top-of-buffer.el --- Tests for cj/clear-to-top-of-buffer -*- lexical-binding: t; -*- ;;; Commentary: -;; Tests for the cj/clear-to-top-of-buffer function from custom-file-buffer.el +;; Tests for the cj/clear-to-top-of-buffer function from custom-buffer-file.el ;; ;; This function deletes all text from point to the beginning of the current buffer. ;; It does not save the deleted text in the kill ring. @@ -22,7 +22,7 @@ (provide 'ps-print) ;; Now load the actual production module -(require 'custom-file-buffer) +(require 'custom-buffer-file) ;;; Setup and Teardown @@ -158,5 +158,5 @@ (should-error (cj/clear-to-top-of-buffer))) (test-clear-to-top-teardown))) -(provide 'test-custom-file-buffer-clear-to-top-of-buffer) -;;; test-custom-file-buffer-clear-to-top-of-buffer.el ends here +(provide 'test-custom-buffer-file-clear-to-top-of-buffer) +;;; test-custom-buffer-file-clear-to-top-of-buffer.el ends here diff --git a/tests/test-custom-file-buffer-copy-link-to-buffer-file.el b/tests/test-custom-buffer-file-copy-link-to-buffer-file.el index 94d1e01e..262968d6 100644 --- a/tests/test-custom-file-buffer-copy-link-to-buffer-file.el +++ b/tests/test-custom-buffer-file-copy-link-to-buffer-file.el @@ -1,7 +1,7 @@ -;;; test-custom-file-buffer-copy-link-to-buffer-file.el --- Tests for cj/copy-link-to-buffer-file -*- lexical-binding: t; -*- +;;; test-custom-buffer-file-copy-link-to-buffer-file.el --- Tests for cj/copy-link-to-buffer-file -*- lexical-binding: t; -*- ;;; Commentary: -;; Tests for the cj/copy-link-to-buffer-file function from custom-file-buffer.el +;; Tests for the cj/copy-link-to-buffer-file function from custom-buffer-file.el ;; ;; This function copies the full file:// path of the current buffer's file to ;; the kill ring. For non-file buffers, it does nothing (no error). @@ -22,7 +22,7 @@ (provide 'ps-print) ;; Now load the actual production module -(require 'custom-file-buffer) +(require 'custom-buffer-file) ;;; Setup and Teardown @@ -205,5 +205,5 @@ (should (null kill-ring)))) (test-copy-link-teardown))) -(provide 'test-custom-file-buffer-copy-link-to-buffer-file) -;;; test-custom-file-buffer-copy-link-to-buffer-file.el ends here +(provide 'test-custom-buffer-file-copy-link-to-buffer-file) +;;; test-custom-buffer-file-copy-link-to-buffer-file.el ends here diff --git a/tests/test-custom-file-buffer-copy-path-to-buffer-file-as-kill.el b/tests/test-custom-buffer-file-copy-path-to-buffer-file-as-kill.el index e7a6f64b..08959a85 100644 --- a/tests/test-custom-file-buffer-copy-path-to-buffer-file-as-kill.el +++ b/tests/test-custom-buffer-file-copy-path-to-buffer-file-as-kill.el @@ -1,7 +1,7 @@ -;;; test-custom-file-buffer-copy-path-to-buffer-file-as-kill.el --- Tests for cj/copy-path-to-buffer-file-as-kill -*- lexical-binding: t; -*- +;;; test-custom-buffer-file-copy-path-to-buffer-file-as-kill.el --- Tests for cj/copy-path-to-buffer-file-as-kill -*- lexical-binding: t; -*- ;;; Commentary: -;; Tests for the cj/copy-path-to-buffer-file-as-kill function from custom-file-buffer.el +;; Tests for the cj/copy-path-to-buffer-file-as-kill function from custom-buffer-file.el ;; ;; This function copies the full path of the current buffer's file to the kill ring ;; and returns the path. It signals an error if the buffer is not visiting a file. @@ -22,7 +22,7 @@ (provide 'ps-print) ;; Now load the actual production module -(require 'custom-file-buffer) +(require 'custom-buffer-file) ;;; Setup and Teardown @@ -201,5 +201,5 @@ (should-error (cj/copy-path-to-buffer-file-as-kill) :type 'user-error)) (test-copy-path-teardown))) -(provide 'test-custom-file-buffer-copy-path-to-buffer-file-as-kill) -;;; test-custom-file-buffer-copy-path-to-buffer-file-as-kill.el ends here +(provide 'test-custom-buffer-file-copy-path-to-buffer-file-as-kill) +;;; test-custom-buffer-file-copy-path-to-buffer-file-as-kill.el ends here diff --git a/tests/test-custom-file-buffer-copy-whole-buffer.el b/tests/test-custom-buffer-file-copy-whole-buffer.el index a0546b18..181c491a 100644 --- a/tests/test-custom-file-buffer-copy-whole-buffer.el +++ b/tests/test-custom-buffer-file-copy-whole-buffer.el @@ -1,7 +1,7 @@ -;;; test-custom-file-buffer-copy-whole-buffer.el --- Tests for cj/copy-whole-buffer -*- lexical-binding: t; -*- +;;; test-custom-buffer-file-copy-whole-buffer.el --- Tests for cj/copy-whole-buffer -*- lexical-binding: t; -*- ;;; Commentary: -;; Tests for the cj/copy-whole-buffer function from custom-file-buffer.el +;; Tests for the cj/copy-whole-buffer function from custom-buffer-file.el ;; ;; This function copies the entire contents of the current buffer to the kill ring. ;; Point and mark are left exactly where they were. No transient region is created. @@ -22,7 +22,7 @@ (provide 'ps-print) ;; Now load the actual production module -(require 'custom-file-buffer) +(require 'custom-buffer-file) ;;; Setup and Teardown @@ -190,5 +190,5 @@ (should (null (text-properties-at 0 (car kill-ring))))) (test-copy-whole-buffer-teardown))) -(provide 'test-custom-file-buffer-copy-whole-buffer) -;;; test-custom-file-buffer-copy-whole-buffer.el ends here +(provide 'test-custom-buffer-file-copy-whole-buffer) +;;; test-custom-buffer-file-copy-whole-buffer.el ends here diff --git a/tests/test-custom-file-buffer-delete-buffer-and-file.el b/tests/test-custom-buffer-file-delete-buffer-and-file.el index 1c43ff3b..4af8d2a7 100644 --- a/tests/test-custom-file-buffer-delete-buffer-and-file.el +++ b/tests/test-custom-buffer-file-delete-buffer-and-file.el @@ -1,7 +1,7 @@ -;;; test-custom-file-buffer-delete-buffer-and-file.el --- Tests for cj/delete-buffer-and-file -*- lexical-binding: t; -*- +;;; test-custom-buffer-file-delete-buffer-and-file.el --- Tests for cj/delete-buffer-and-file -*- lexical-binding: t; -*- ;;; Commentary: -;; Tests for the cj/delete-buffer-and-file function from custom-file-buffer.el +;; Tests for the cj/delete-buffer-and-file function from custom-buffer-file.el ;; ;; This function deletes both the current buffer and the file it visits. ;; It uses vc-delete-file for version-controlled files and delete-file @@ -42,7 +42,7 @@ (provide 'ps-print) ;; Now load the actual production module -(require 'custom-file-buffer) +(require 'custom-buffer-file) ;;; Setup and Teardown @@ -667,5 +667,5 @@ (should-error (cj/delete-buffer-and-file)))) (test-delete-buffer-and-file-teardown))) -(provide 'test-custom-file-buffer-delete-buffer-and-file) -;;; test-custom-file-buffer-delete-buffer-and-file.el ends here +(provide 'test-custom-buffer-file-delete-buffer-and-file) +;;; test-custom-buffer-file-delete-buffer-and-file.el ends here diff --git a/tests/test-custom-file-buffer-move-buffer-and-file.el b/tests/test-custom-buffer-file-move-buffer-and-file.el index 1fc16011..e8f4563d 100644 --- a/tests/test-custom-file-buffer-move-buffer-and-file.el +++ b/tests/test-custom-buffer-file-move-buffer-and-file.el @@ -1,7 +1,7 @@ -;;; test-custom-file-buffer-move-buffer-and-file.el --- Tests for cj/move-buffer-and-file -*- lexical-binding: t; -*- +;;; test-custom-buffer-file-move-buffer-and-file.el --- Tests for cj/move-buffer-and-file -*- lexical-binding: t; -*- ;;; Commentary: -;; Tests for the cj/--move-buffer-and-file function from custom-file-buffer.el +;; Tests for the cj/--move-buffer-and-file function from custom-buffer-file.el ;; ;; This is the internal (non-interactive) implementation that moves both the ;; current buffer and its visited file to a new directory. It handles trailing @@ -25,7 +25,7 @@ (provide 'ps-print) ;; Now load the actual production module -(require 'custom-file-buffer) +(require 'custom-buffer-file) ;;; Setup and Teardown @@ -932,5 +932,5 @@ (kill-buffer (current-buffer))) (test-move-buffer-and-file-teardown))) -(provide 'test-custom-file-buffer-move-buffer-and-file) -;;; test-custom-file-buffer-move-buffer-and-file.el ends here +(provide 'test-custom-buffer-file-move-buffer-and-file) +;;; test-custom-buffer-file-move-buffer-and-file.el ends here diff --git a/tests/test-custom-file-buffer-rename-buffer-and-file.el b/tests/test-custom-buffer-file-rename-buffer-and-file.el index ca8acff8..1eb61f1b 100644 --- a/tests/test-custom-file-buffer-rename-buffer-and-file.el +++ b/tests/test-custom-buffer-file-rename-buffer-and-file.el @@ -1,7 +1,7 @@ -;;; test-custom-file-buffer-rename-buffer-and-file.el --- Tests for cj/--rename-buffer-and-file -*- lexical-binding: t; -*- +;;; test-custom-buffer-file-rename-buffer-and-file.el --- Tests for cj/--rename-buffer-and-file -*- lexical-binding: t; -*- ;;; Commentary: -;; Tests for the cj/--rename-buffer-and-file function from custom-file-buffer.el +;; Tests for the cj/--rename-buffer-and-file function from custom-buffer-file.el ;; ;; This is the internal (non-interactive) implementation that renames both the ;; current buffer and its visited file. The interactive wrapper @@ -24,7 +24,7 @@ (provide 'ps-print) ;; Now load the actual production module -(require 'custom-file-buffer) +(require 'custom-buffer-file) ;;; Setup and Teardown @@ -935,5 +935,5 @@ (kill-buffer (current-buffer))) (test-rename-buffer-and-file-teardown))) -(provide 'test-custom-file-buffer-rename-buffer-and-file) -;;; test-custom-file-buffer-rename-buffer-and-file.el ends here +(provide 'test-custom-buffer-file-rename-buffer-and-file) +;;; test-custom-buffer-file-rename-buffer-and-file.el ends here diff --git a/tests/test-org-gcal-mock.el b/tests/test-org-gcal-mock.el new file mode 100644 index 00000000..4b063867 --- /dev/null +++ b/tests/test-org-gcal-mock.el @@ -0,0 +1,112 @@ +;;; test-org-gcal-mock.el --- Mock test for org-gcal sync -*- lexical-binding: t; -*- + +;;; Commentary: +;; Mock test to capture what org-gcal sends to Google Calendar API +;; This helps debug bidirectional sync issues without hitting the real API + +;;; Code: + +(require 'ert) +(require 'org) + +;; Add modules directory to load path +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) + +;; Load org-gcal (this will require auth, but we'll mock the requests) +(require 'org-gcal-config nil t) + +;; Variables to capture requests +(defvar test-org-gcal-captured-requests nil + "List of captured HTTP requests.") + +(defvar test-org-gcal-captured-url nil + "Last captured URL.") + +(defvar test-org-gcal-captured-type nil + "Last captured HTTP method (GET/POST/PUT/PATCH).") + +(defvar test-org-gcal-captured-data nil + "Last captured request body/data.") + +(defvar test-org-gcal-captured-headers nil + "Last captured request headers.") + +;;; Mock request-deferred to capture what org-gcal sends + +(defun test-org-gcal-mock-request-deferred (url &rest args) + "Mock request-deferred to capture requests instead of sending them. +URL is the API endpoint. ARGS contains :type, :data, :headers, etc." + (let* ((type (plist-get args :type)) + (data (plist-get args :data)) + (headers (plist-get args :headers))) + ;; Capture the request + (setq test-org-gcal-captured-url url) + (setq test-org-gcal-captured-type type) + (setq test-org-gcal-captured-data data) + (setq test-org-gcal-captured-headers headers) + (push (list :url url + :type type + :data data + :headers headers) + test-org-gcal-captured-requests) + + ;; Print for debugging + (message "MOCK REQUEST: %s %s" type url) + (when data + (message "MOCK DATA: %S" data)) + + ;; Return a mock deferred object that succeeds immediately + (require 'deferred) + (deferred:succeed + ;; Mock response with a fake event + (list :data '(:id "test-event-id-123" + :etag "test-etag-456" + :summary "Test Event" + :start (:dateTime "2025-10-28T14:00:00-05:00") + :end (:dateTime "2025-10-28T15:00:00-05:00")) + :status-code 200)))) + +(ert-deftest test-org-gcal-capture-post-request () + "Test capturing what org-gcal sends when posting an event." + ;; Reset captured requests + (setq test-org-gcal-captured-requests nil) + (setq test-org-gcal-captured-url nil) + (setq test-org-gcal-captured-type nil) + (setq test-org-gcal-captured-data nil) + + ;; Mock request-deferred + (cl-letf (((symbol-function 'request-deferred) #'test-org-gcal-mock-request-deferred)) + + ;; Create a test org buffer with an event + (with-temp-buffer + (org-mode) + (insert "* TEST: Mock Sync Test Event\n") + (insert "<2025-10-28 Tue 14:00-15:00>\n") + (insert "\n") + (insert "Test event for mocking.\n") + + ;; Go to the headline + (goto-char (point-min)) + (org-back-to-heading) + + ;; Try to post (this should be captured by our mock) + (condition-case err + (org-gcal-post-at-point) + (error + (message "Error during post: %S" err))))) + + ;; Check what was captured + (should test-org-gcal-captured-requests) + (let ((request (car test-org-gcal-captured-requests))) + (message "Captured URL: %s" (plist-get request :url)) + (message "Captured Type: %s" (plist-get request :type)) + (message "Captured Data: %S" (plist-get request :data)) + + ;; Verify it's trying to POST/PATCH + (should (member (plist-get request :type) '("POST" "PATCH" "PUT"))) + + ;; Verify URL contains calendar API + (should (string-match-p "googleapis.com/calendar" (plist-get request :url))))) + +(provide 'test-org-gcal-mock) +;;; test-org-gcal-mock.el ends here |
