Skip to content

Commit de2146c

Browse files
committed
Rename file impostman-tests.el to impostman-test.el, rename test functions
This fixes linter errors on the test suite package.
1 parent 0d81a47 commit de2146c

File tree

2 files changed

+62
-51
lines changed

2 files changed

+62
-51
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ compile:
2626
$(EMACS) -Q -batch --eval "(setq byte-compile-error-on-warn t)" -f batch-byte-compile impostman.el
2727

2828
test: clean
29-
$(EMACS) -Q -batch -L . -l impostman -l tests/impostman-tests -f ert-run-tests-batch-and-exit
29+
$(EMACS) -Q -batch -L . -l impostman -l tests/impostman-test -f ert-run-tests-batch-and-exit
3030

3131
clean:
3232
$(RM) *.elc
Lines changed: 61 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
;;; impostman-tests.el --- Tests on impostman.el -*- lexical-binding: t -*-
1+
;;; impostman-test.el --- Test suite for impostman -*- lexical-binding: t -*-
22

33
;; Copyright (C) 2020-2021 Sébastien Helleu <flashcode@flashtux.org>
44

@@ -28,20 +28,20 @@
2828

2929
;;; Commentary:
3030

31-
;; Tests on impostman.el
31+
;; Test suite for impostman.
3232

3333
;;; Code:
3434

3535
(require 'ert)
3636
(require 'impostman)
3737

38-
(defun get-file-contents (filename)
38+
(defun impostman-test--get-file-contents (filename)
3939
"Get contents of filename."
4040
(with-temp-buffer
4141
(insert-file-contents filename)
4242
(buffer-string)))
4343

44-
(ert-deftest impostman-format-comment ()
44+
(ert-deftest impostman-test-format-comment ()
4545
"Test the format of comment."
4646
;; without prefix: default is "# "
4747
(should (equal (impostman-format-comment nil)
@@ -75,7 +75,7 @@
7575
";; Line 2\n"
7676
";; Line 3\n"))))
7777

78-
(ert-deftest impostman-add-query-string-items-to-url ()
78+
(ert-deftest impostman-test-add-query-string-items-to-url ()
7979
"Test add of query-string items to an URL."
8080
(should (equal (impostman-add-query-string-items-to-url
8181
"https://example.com" nil)
@@ -87,7 +87,7 @@
8787
"https://example.com?a=1" '(("apikey" . "1a2b3c4d")))
8888
"https://example.com?a=1&apikey=1a2b3c4d")))
8989

90-
(ert-deftest impostman-get-auth-basic-plain ()
90+
(ert-deftest impostman-test-get-auth-basic-plain ()
9191
"Test the base64 decoding of Authorization Basic header."
9292
(should (equal (impostman-get-auth-basic-plain "")
9393
nil))
@@ -99,15 +99,15 @@
9999
"Basic dXNlcm5hbWU6cGFzc3dvcmQ=")
100100
"username:password")))
101101

102-
(ert-deftest impostman-output-verb-header ()
102+
(ert-deftest impostman-test-output-verb-header ()
103103
"Test the output of verb header."
104104
(should (equal (impostman-output-verb-header "test" "Description\nLine 2")
105105
(concat
106106
"* test :verb:\n"
107107
"# Description\n"
108108
"# Line 2\n"))))
109109

110-
(ert-deftest impostman-output-verb-item ()
110+
(ert-deftest impostman-test-output-verb-item ()
111111
"Test the output of verb item."
112112
(should (equal (impostman-output-verb-item 0 "test" "")
113113
(concat
@@ -147,7 +147,7 @@
147147
"# Description\n"
148148
"# end.\n"))))
149149

150-
(ert-deftest impostman-output-verb-request ()
150+
(ert-deftest impostman-test-output-verb-request ()
151151
"Test the output of verb request."
152152
(should (equal (impostman-output-verb-request
153153
""
@@ -219,7 +219,7 @@
219219
"header: value\n"
220220
"\n{\"login\": \"admin\"}\n")))))
221221

222-
(ert-deftest impostman-output-verb-footer ()
222+
(ert-deftest impostman-test-output-verb-footer ()
223223
"Test the output of verb footer."
224224
(should (equal (impostman-output-verb-footer "test")
225225
(concat
@@ -230,7 +230,7 @@
230230
"# eval: (verb-mode)\n"
231231
"# End:\n"))))
232232

233-
(ert-deftest impostman-output-restclient-header ()
233+
(ert-deftest impostman-test-output-restclient-header ()
234234
"Test the output of restclient header."
235235
(should (equal (impostman-output-restclient-header
236236
"test" "Description\nLine 2")
@@ -242,7 +242,7 @@
242242
"# Line 2\n"
243243
"#\n"))))
244244

245-
(ert-deftest impostman-output-restclient-item ()
245+
(ert-deftest impostman-test-output-restclient-item ()
246246
"Test the output of restclient item."
247247
(should (equal (impostman-output-restclient-item 0 "test" "")
248248
(concat
@@ -258,31 +258,35 @@
258258
"## test\n")))
259259
(should (equal (impostman-output-restclient-item 3 "test" "")
260260
"### test\n"))
261-
(should (equal (impostman-output-restclient-item 0 "test" "Description\nend.")
261+
(should (equal (impostman-output-restclient-item
262+
0 "test" "Description\nend.")
262263
(concat
263264
"\n"
264265
"# test\n"
265266
"# Description\n"
266267
"# end.\n")))
267-
(should (equal (impostman-output-restclient-item 1 "test" "Description\nend.")
268+
(should (equal (impostman-output-restclient-item
269+
1 "test" "Description\nend.")
268270
(concat
269271
"\n"
270272
"# test\n"
271273
"# Description\n"
272274
"# end.\n")))
273-
(should (equal (impostman-output-restclient-item 2 "test" "Description\nend.")
275+
(should (equal (impostman-output-restclient-item
276+
2 "test" "Description\nend.")
274277
(concat
275278
"\n"
276279
"## test\n"
277280
"# Description\n"
278281
"# end.\n")))
279-
(should (equal (impostman-output-restclient-item 3 "test" "Description\nend.")
282+
(should (equal (impostman-output-restclient-item
283+
3 "test" "Description\nend.")
280284
(concat
281285
"### test\n"
282286
"# Description\n"
283287
"# end.\n"))))
284288

285-
(ert-deftest impostman-output-restclient-request ()
289+
(ert-deftest impostman-test-output-restclient-request ()
286290
"Test the output of restclient request."
287291
(should (equal (impostman-output-restclient-request
288292
""
@@ -355,14 +359,14 @@
355359
"header: value\n"
356360
"{\"login\": \"admin\"}\n")))))
357361

358-
(ert-deftest impostman-output-restclient-footer ()
362+
(ert-deftest impostman-test-output-restclient-footer ()
359363
"Test the output of restclient footer."
360364
(should (equal (impostman-output-restclient-footer "test")
361365
(concat
362366
"\n"
363367
"# End of test\n"))))
364368

365-
(ert-deftest impostman--build-auth-headers ()
369+
(ert-deftest impostman-test-build-auth-headers ()
366370
"Test the build of auth headers."
367371
(let ((auth (make-hash-table :test 'equal))
368372
(username #s(hash-table test equal data ("key" "username"
@@ -422,7 +426,7 @@
422426
(should (equal (impostman--build-auth-headers auth)
423427
nil))))
424428

425-
(ert-deftest impostman--build-headers ()
429+
(ert-deftest impostman-test-build-headers ()
426430
"Test the build of headers."
427431
(let ((header1 #s(hash-table test equal data ("key" "header1"
428432
"value" "value1")))
@@ -444,7 +448,7 @@
444448
("header1" . "value1")
445449
("X-header2" . "the value 2"))))))
446450

447-
(ert-deftest impostman--build-auth-query-string ()
451+
(ert-deftest impostman-test-build-auth-query-string ()
448452
"Test build of query-string parameter for authentication."
449453
(let ((auth (make-hash-table :test 'equal))
450454
(apikey-key #s(hash-table test equal data ("key" "key"
@@ -463,7 +467,7 @@
463467
(should (equal (impostman--build-auth-query-string auth)
464468
'(("apikey" . "1a2b3c4d"))))))
465469

466-
(ert-deftest impostman--parse-item ()
470+
(ert-deftest impostman-test-parse-item ()
467471
"Test parsing of an item."
468472
(let ((item1 (make-hash-table :test 'equal))
469473
(request1 (make-hash-table :test 'equal))
@@ -578,7 +582,7 @@
578582
"\n"
579583
"{\"key\": \"data\"}\n"))))))
580584

581-
(ert-deftest impostman--parse-json ()
585+
(ert-deftest impostman-test-parse-json ()
582586
"Test parsing of a JSON collection."
583587
(let ((collection (make-hash-table :test 'equal))
584588
(info (make-hash-table :test 'equal)))
@@ -633,20 +637,20 @@
633637
"# End:\n"))))
634638
(kill-this-buffer))))
635639

636-
(defun impostman-output-test-header (name description)
640+
(defun impostman-test-output-test-header (name description)
637641
"Format the test header."
638642
(concat
639643
"* " name " :test:\n"
640644
(impostman-format-comment description)))
641645

642-
(defun impostman-output-test-item (level name description)
646+
(defun impostman-test-output-test-item (level name description)
643647
"Format a test item."
644648
(concat
645649
(if (<= level 2) "\n" "")
646650
(make-string (max level 1) ?*) " " name "\n"
647651
(impostman-format-comment description)))
648652

649-
(defun impostman-output-test-request (description method url headers body)
653+
(defun impostman-test-output-test-request (description method url headers body)
650654
"Format a test request."
651655
(let ((list-headers))
652656
(dolist (header headers)
@@ -658,26 +662,29 @@
658662
(concat (string-join (nreverse list-headers) "\n") "\n"))
659663
(if (string-empty-p body) "" (concat "\n" body "\n")))))
660664

661-
(defun impostman-output-test-footer (name)
665+
(defun impostman-test-output-test-footer (name)
662666
"Format the test footer."
663667
(concat "\n" "* End of " name "\n"))
664668

665-
(ert-deftest impostman-import-file ()
669+
(ert-deftest impostman-test-import-file ()
666670
"Test import of a file with a Postman collection."
667-
(setq impostman-output-test-alist
671+
(setq impostman-test-output-test-alist
668672
'((init . ignore)
669-
(header . impostman-output-test-header)
670-
(item . impostman-output-test-item)
671-
(request . impostman-output-test-request)
672-
(footer . impostman-output-test-footer)
673+
(header . impostman-test-output-test-header)
674+
(item . impostman-test-output-test-item)
675+
(request . impostman-test-output-test-request)
676+
(footer . impostman-test-output-test-footer)
673677
(end . ignore)))
674-
(let* ((verb-output (get-file-contents "tests/verb.org"))
675-
(restclient-output (get-file-contents "tests/restclient.org"))
676-
(test-output (get-file-contents "tests/test.org"))
678+
(let* ((verb-output
679+
(impostman-test--get-file-contents "tests/verb.org"))
680+
(restclient-output
681+
(impostman-test--get-file-contents "tests/restclient.org"))
682+
(test-output
683+
(impostman-test--get-file-contents "tests/test.org"))
677684
(impostman-outputs-alist
678685
'(("verb" . impostman-output-verb-alist)
679686
("restclient" . impostman-output-restclient-alist)
680-
("test" . impostman-output-test-alist))))
687+
("test" . impostman-test-output-test-alist))))
681688
(save-excursion
682689
(impostman-import-file "tests/collection.json" "verb")
683690
(should (string-prefix-p "test.org" (buffer-name)))
@@ -698,23 +705,27 @@
698705
(kill-this-buffer)))
699706
(makunbound 'impostman-output-test-alist))
700707

701-
(ert-deftest impostman-import-string ()
708+
(ert-deftest impostman-test-import-string ()
702709
"Test import of a string with a Postman collection."
703-
(setq impostman-output-test-alist
710+
(setq impostman-test-output-test-alist
704711
'((init . ignore)
705-
(header . impostman-output-test-header)
706-
(item . impostman-output-test-item)
707-
(request . impostman-output-test-request)
708-
(footer . impostman-output-test-footer)
712+
(header . impostman-test-output-test-header)
713+
(item . impostman-test-output-test-item)
714+
(request . impostman-test-output-test-request)
715+
(footer . impostman-test-output-test-footer)
709716
(end . ignore)))
710-
(let* ((collection (get-file-contents "tests/collection.json"))
711-
(verb-output (get-file-contents "tests/verb.org"))
712-
(restclient-output (get-file-contents "tests/restclient.org"))
713-
(test-output (get-file-contents "tests/test.org"))
717+
(let* ((collection
718+
(impostman-test--get-file-contents "tests/collection.json"))
719+
(verb-output
720+
(impostman-test--get-file-contents "tests/verb.org"))
721+
(restclient-output
722+
(impostman-test--get-file-contents "tests/restclient.org"))
723+
(test-output
724+
(impostman-test--get-file-contents "tests/test.org"))
714725
(impostman-outputs-alist
715726
'(("verb" . impostman-output-verb-alist)
716727
("restclient" . impostman-output-restclient-alist)
717-
("test" . impostman-output-test-alist))))
728+
("test" . impostman-test-output-test-alist))))
718729
(save-excursion
719730
(impostman-import-string collection "verb")
720731
(should (string-prefix-p "test.org" (buffer-name)))
@@ -735,6 +746,6 @@
735746
(kill-this-buffer)))
736747
(makunbound 'impostman-output-test-alist))
737748

738-
(provide 'impostman-tests)
749+
(provide 'impostman-test)
739750

740-
;;; impostman-tests.el ends here
751+
;;; impostman-test.el ends here

0 commit comments

Comments
 (0)