summaryrefslogtreecommitdiff
path: root/tests/test-wttrin-smoke.el
blob: 07a718a90456639dd91458c3241abbe360c5243c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
;;; test-wttrin-smoke.el --- Smoke tests for wttrin package loading -*- lexical-binding: t; -*-

;; Copyright (C) 2024-2026 Craig Jennings

;;; Commentary:
;; Smoke tests to verify wttrin package loads correctly and core
;; infrastructure is available.  These are sanity checks that catch:
;; - Package installation issues
;; - Missing dependencies
;; - Public API breakage
;; - Autoload cookie problems
;; - Package metadata issues
;;
;; These tests do NOT test functionality (that's in unit tests).
;; They only verify that functions/variables exist and have correct types.

;;; Code:

(require 'ert)
(require 'wttrin)
(require 'testutil-wttrin)

;;; Setup and Teardown

(defun test-wttrin-smoke-setup ()
  "Setup for smoke tests."
  (testutil-wttrin-setup))

(defun test-wttrin-smoke-teardown ()
  "Teardown for smoke tests."
  (testutil-wttrin-teardown))

;;; Package Loading Tests

(ert-deftest test-wttrin-smoke-package-loads ()
  "Test that wttrin package loads without errors.
If we got here, the package loaded successfully via (require 'wttrin)."
  (should t))

(ert-deftest test-wttrin-smoke-provide-statement ()
  "Test that wttrin feature is provided."
  (should (featurep 'wttrin)))

;;; Dependency Tests

(ert-deftest test-wttrin-smoke-xterm-color-available ()
  "Test that xterm-color dependency can be loaded when needed.
This is a REQUIRED dependency - wttrin cannot function without it."
  (should (require 'xterm-color nil t)))

(ert-deftest test-wttrin-smoke-url-available ()
  "Test that url library is available (built-in)."
  (should (require 'url nil t)))

;;; Function Availability Tests

(ert-deftest test-wttrin-smoke-main-command-defined ()
  "Test that main wttrin command is defined."
  (should (fboundp 'wttrin)))

(ert-deftest test-wttrin-smoke-main-command-is-interactive ()
  "Test that main wttrin command is interactive."
  (should (commandp 'wttrin)))

(ert-deftest test-wttrin-smoke-wttrin-mode-defined ()
  "Test that wttrin-mode is defined."
  (should (fboundp 'wttrin-mode)))

(ert-deftest test-wttrin-smoke-mode-line-mode-defined ()
  "Test that wttrin-mode-line-mode is defined."
  (should (fboundp 'wttrin-mode-line-mode)))

(ert-deftest test-wttrin-smoke-clear-cache-defined ()
  "Test that cache clear command is defined."
  (should (fboundp 'wttrin-clear-cache)))

;;; Configuration Variable Tests

(ert-deftest test-wttrin-smoke-defcustoms-exist ()
  "Test that key defcustom variables are defined."
  (should (boundp 'wttrin-default-locations))
  (should (boundp 'wttrin-unit-system))
  (should (boundp 'wttrin-refresh-interval))
  (should (boundp 'wttrin-cache-max-entries))
  (should (boundp 'wttrin-favorite-location))
  (should (boundp 'wttrin-mode-line-refresh-interval))
  (should (boundp 'wttrin-mode-line-startup-delay)))

(ert-deftest test-wttrin-smoke-internal-vars-exist ()
  "Test that internal variables are defined."
  (should (boundp 'wttrin--cache))
  (should (boundp 'wttrin--mode-line-map))
  (should (boundp 'wttrin-mode-line-string)))

;;; Keymap Tests

(ert-deftest test-wttrin-smoke-wttrin-mode-map-exists ()
  "Test that wttrin-mode keymap exists and is a keymap."
  (should (boundp 'wttrin-mode-map))
  (should (keymapp wttrin-mode-map)))

(ert-deftest test-wttrin-smoke-mode-line-map-exists ()
  "Test that mode-line keymap exists and is a keymap."
  (should (boundp 'wttrin--mode-line-map))
  (should (keymapp wttrin--mode-line-map)))

;;; Package Metadata Tests

(ert-deftest test-wttrin-smoke-package-version ()
  "Test that package has version information in correct format."
  ;; Verify the Version header exists in the file
  (let ((version-line (with-temp-buffer
                        (insert-file-contents "wttrin.el" nil 0 500)
                        (goto-char (point-min))
                        (re-search-forward "^;; Version: \\([0-9.]+\\)" nil t)
                        (match-string 1))))
    (should version-line)
    (should (string-match-p "^[0-9]+\\.[0-9]+\\.[0-9]+$" version-line))))

(ert-deftest test-wttrin-smoke-autoload-cookies ()
  "Test that key functions have autoload cookies in source."
  ;; Verify autoload cookies exist (they become effective after package install)
  (let ((source (with-temp-buffer
                  (insert-file-contents "wttrin.el")
                  (buffer-string))))
    ;; Main command should have autoload
    (should (string-match-p ";;;###autoload\n(defun wttrin" source))
    ;; Mode-line mode should have autoload
    (should (string-match-p ";;;###autoload\n(define-minor-mode wttrin-mode-line-mode" source))))

(provide 'test-wttrin-smoke)
;;; test-wttrin-smoke.el ends here