diff --git a/impostman.el b/impostman.el index 8ba4e3e..e311e29 100644 --- a/impostman.el +++ b/impostman.el @@ -86,6 +86,15 @@ Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=" ;; utility functions +(defun impostman-version (&optional print-dest) + "Return the Impostman version. + +PRINT-DEST is the output stream, by default the echo area. + +With \\[universal-argument] prefix, output is in the current buffer." + (interactive (list (if current-prefix-arg (current-buffer) t))) + (princ (format "impostman %s" impostman-version) print-dest)) + (defun impostman-format-comment (comment &optional prefix) "Format a comment, which can be on multiple lines. diff --git a/tests/impostman-test.el b/tests/impostman-test.el index c520bdc..11e8df8 100644 --- a/tests/impostman-test.el +++ b/tests/impostman-test.el @@ -41,6 +41,15 @@ (insert-file-contents filename) (buffer-string))) +(ert-deftest impostman-test-version () + "Test Impostman version." + (let ((impostman-version-output (impostman-version)) + (expected-string-version (concat "impostman " impostman-version))) + ;; version must include at least 3 digits, separated by dots + (should (string-match "^impostman [0-9]+\\.[0-9]+\\.[0-9]+" + impostman-version-output)) + (should (equal impostman-version-output expected-string-version)))) + (ert-deftest impostman-test-format-comment () "Test the format of comment." ;; without prefix: default is "# "