Up the coverage a notch

This commit is contained in:
Carlo Sciolla 2019-05-31 10:36:28 +02:00
parent 5cb10712d3
commit 676888feb0
No known key found for this signature in database
GPG Key ID: BA5D71E6F3C580C1
2 changed files with 47 additions and 12 deletions

View File

@ -161,18 +161,20 @@
(defvar-local plantuml-exec-mode plantuml-default-exec-mode
"The Plantuml execution mode. See `plantuml-default-exec-mode' for acceptable values.")
(defun plantuml-set-exec-mode ()
"Set the execution mode for PlantUML."
(interactive)
(let* ((completion-ignore-case t)
(supported-modes '("jar" "server")))
(setq plantuml-exec-mode (intern (completing-read (format "Exec mode [%s]: " plantuml-exec-mode)
supported-modes
nil
t
nil
nil
plantuml-exec-mode)))))
(defun plantuml-set-exec-mode (mode)
"Set the execution mode MODE for PlantUML."
(interactive (let* ((completion-ignore-case t)
(supported-modes '("jar" "server")))
(completing-read (format "Exec mode [%s]: " plantuml-exec-mode)
supported-modes
nil
t
nil
nil
plantuml-exec-mode)))
(if (member mode '("jar" "server"))
(setq plantuml-exec-mode (intern mode))
(error (concat "Unsupported mode:" mode))))
(defun plantuml-enable-debug ()
"Enables debug messages into the *PLANTUML Messages* buffer."

View File

@ -0,0 +1,33 @@
;;; plantuml-config-test.el --- tests for plantuml-mode configuration knobs -*- lexical-binding: t; -*-
;; Author: Carlo Sciolla
;; Maintainer: Carlo Sciolla
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;; Test user-accessible configuration knobs
;;; Code:
(require 'plantuml-mode)
(ert-deftest plantuml-config-test/set-exec-mode-happy-path ()
"Test switching execution modes"
(let ((orig-mode plantuml-exec-mode))
;; happy flows:
(plantuml-set-exec-mode "server")
(should (equal 'server plantuml-exec-mode))
(plantuml-set-exec-mode "jar")
(should (equal 'jar plantuml-exec-mode))
(setq plantuml-exec-mode orig-mode)))
(ert-deftest plantuml-config-test/set-exec-mode-wrong-mode ()
"Test setting the exec mode with the wrong text"
:expected-result :failed
(plantuml-set-exec-mode "turing-machine"))
(provide 'plantuml-mode-config-test)
;;; plantuml-config-test.el ends here