-
Notifications
You must be signed in to change notification settings - Fork 5
/
grails-test.el
90 lines (85 loc) · 3.52 KB
/
grails-test.el
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
(require 'ert)
(require 'grails)
(ert-deftest grails-test-vars-1 ()
"Test mode vars"
(should (eql (length grails-dir-name-by-type) 4))
(should (string= (car (cdr (assoc 'controller grails-dir-name-by-type))) "controllers"))
(should (string= (car (cdr (assoc 'domain grails-dir-name-by-type))) "domain"))
(should (string= (car (cdr (assoc 'service grails-dir-name-by-type))) "services"))
(should (string= (car (cdr (assoc 'view grails-dir-name-by-type))) "views")))
(ert-deftest grails-test-vars-2 ()
"Test mode vars"
(should (eql (length grails-postfix-by-type) 4))
(should (string= (car (cdr (assoc 'controller grails-postfix-by-type))) "Controller.groovy"))
(should (string= (car (cdr (assoc 'domain grails-postfix-by-type))) ".groovy"))
(should (string= (car (cdr (assoc 'service grails-postfix-by-type))) "Service.groovy"))
(should (string= (car (cdr (assoc 'view grails-postfix-by-type))) ".gsp")))
(ert-deftest grails-test-grails-grep-version ()
"Test version detection"
(should (eql (grails-grep-version "grailsVersion=3.1.0") 3))
(should-not (eql (grails-grep-version "grailsVersion=2.1.0") 2));;only 3+ has gradle
(should (eql (grails-grep-version "app.grails.version=2.1.0") 2))
(should (eql (grails-grep-version "WrongProperty=3.1.0") nil))
(should (eql (grails-grep-version "#comment\nanother.app.grails.version=2") nil))
(should (eql (grails-grep-version "another.grailsVersion=3") nil)))
(ert-deftest grails-test-clean-name ()
"Test the grails-clean-name function."
;; controllers
(should (equal
(grails-clean-name
"~/grails-app/controllers/TestController.groovy")
"Test"))
(should (equal
(grails-clean-name
"~/grails-app/controllers/pkg/TestController.groovy")
"pkg/Test"))
(should-not (equal
(grails-clean-name
"~/grails-app/controllers/pkg/TestController.groovy")
"Test"))
;; domains
(should (equal
(grails-clean-name
"~/grails-app/domain/Test.groovy")
"Test"))
(should (equal
(grails-clean-name
"~/grails-app/domain/pkg/Test.groovy")
"pkg/Test"))
(should-not (equal
(grails-clean-name
"~/grails-app/domain/pkg/Test.groovy")
"Test"))
;; services
(should (equal
(grails-clean-name
"~/grails-app/services/TestService.groovy")
"Test"))
(should (equal
(grails-clean-name
"~/grails-app/services/pkg/TestService.groovy")
"pkg/Test"))
(should-not (equal
(grails-clean-name
"~/grails-app/services/pkg/TestService.groovy")
"Test"))
;; views
(should-error (grails-clean-name
"~/grails-app/views/myView.gsp"))
;; error
(should-error (grails-clean-name
"~/grails-app/custom/Test.groovy")))
(ert-deftest grails-test-dir-by-type-and-name ()
"Test internal function"
(should (equal
(grails-dir-by-type-and-name 'domain "User" "~/grails-app/")
"~/grails-app/domain/User.groovy"))
(should (equal
(grails-dir-by-type-and-name 'controller "User" "~/grails-app/")
"~/grails-app/controllers/UserController.groovy"))
(should (equal
(grails-dir-by-type-and-name 'service "User" "~/grails-app/")
"~/grails-app/services/UserService.groovy"))
(should (equal
(grails-dir-by-type-and-name 'domain "pkg/User" "~/grails-app/")
"~/grails-app/domain/pkg/User.groovy")))