indentation test for deployment diagram

This commit is contained in:
René Schmelzer 2019-03-09 07:47:03 +01:00
parent af6ac38547
commit acec715a6e
3 changed files with 136 additions and 23 deletions

View File

@ -0,0 +1,109 @@
;;; plantuml-indentation-deployment-test.el --- PlantUML Mode indentation tests -*- lexical-binding: t; -*-
;; Author: René Schmelzer
;; Maintainer: Carlo Sciolla (skuro)
;; URL: https://github.com/skuro/plantuml-mode
;;; Commentary:
;; Test indentation for class diagrams.
;; Most plantuml code examples are taken from www.plantuml.com
;;; Code:
(ert-deftest plantuml-test-indentation/deployment-diagram ()
"Test correct indentation of plantuml deployment diagram elements."
(plantuml-test-indent-block
"
artifact Foo1 {
folder Foo2
}
folder Foo3 {
artifact Foo4
}
frame Foo5 {
database Foo6
}
cloud vpc {
node ec2 {
stack stack
}
}
node Foo1 {
cloud Foo2
}
cloud Foo3 {
frame Foo4
}
database Foo5 {
storage Foo6
}
storage Foo7 {
storage Foo8
}
skinparam rectangle {
roundCorner<<Concept>> 25
}
rectangle \"Concept Model\" <<Concept>> {
rectangle \"Example 1\" <<Concept>> as ex1
rectangle \"Another rectangle\"
}
"
"
artifact Foo1 {
folder Foo2
}
folder Foo3 {
artifact Foo4
}
frame Foo5 {
database Foo6
}
cloud vpc {
node ec2 {
stack stack
}
}
node Foo1 {
cloud Foo2
}
cloud Foo3 {
frame Foo4
}
database Foo5 {
storage Foo6
}
storage Foo7 {
storage Foo8
}
skinparam rectangle {
roundCorner<<Concept>> 25
}
rectangle \"Concept Model\" <<Concept>> {
rectangle \"Example 1\" <<Concept>> as ex1
rectangle \"Another rectangle\"
}
"))
(provide 'plantuml-indentation-deployment-test)
;;; plantuml-indentation-deployment-test.el ends here

View File

@ -255,32 +255,9 @@ foofoo|"
foofoo|"))
(defun plantuml-test-indent-block (before after)
"The common code for the block indentation tests.
BEFORE is the text block to be inserted into a temporary buffer.
AFTER is the expected text block after indentation.
The temporary buffer will be put into `plantuml-mode'. The whole buffer
will be indented with two spaces for each level of indentation.
Finally, the indented text in the buffer will be compared with AFTER."
(with-temp-buffer
;; fix the JAR location prior to mode initialization
;; for some reason, plantuml-mode disregards the setq-local
(setq-local plantuml-jar-path plantuml-test-jar-path)
(plantuml-init-once)
(insert before)
(goto-char (point-min))
(plantuml-mode)
;; use 2 spaces instead of one tab for indentation
(setq-local indent-tabs-mode nil)
(setq-local tab-width 2)
(indent-region (point-min) (point-max))
(should (equal (buffer-string) after))))
(ert-deftest plantuml-test-block-indentation/package-empty ()
"Test correct indentation of an empty package block."

View File

@ -39,6 +39,33 @@
"Make the preview output as S more readable in test output."
(concat "\n" s))
(defun plantuml-test-indent-block (before after)
"The common code for the block indentation tests.
BEFORE is the text block to be inserted into a temporary buffer.
AFTER is the expected text block after indentation.
The temporary buffer will be put into `plantuml-mode'. The whole buffer
will be indented with two spaces for each level of indentation.
Finally, the indented text in the buffer will be compared with AFTER."
(with-temp-buffer
;; fix the JAR location prior to mode initialization
;; for some reason, plantuml-mode disregards the setq-local
(setq-local plantuml-jar-path plantuml-test-jar-path)
(plantuml-init-once)
(insert before)
(goto-char (point-min))
(plantuml-mode)
;; use 2 spaces instead of one tab for indentation
(setq-local indent-tabs-mode nil)
(setq-local tab-width 2)
(indent-region (point-min) (point-max))
(should (equal (buffer-string) after))))
;; enable code coverage
(when (require 'undercover nil t)
(undercover "plantuml-mode.el"))