-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.el
62 lines (55 loc) · 2.61 KB
/
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
(require 'package)
(push '("melpa" . "https://melpa.org/packages/") package-archives)
(package-initialize)
(dolist (pkg '(exec-path-from-shell))
(unless (package-installed-p pkg)
(unless (assoc pkg package-archive-contents)
(package-refresh-contents))
(package-install pkg)))
(add-to-list 'load-path (concat (file-name-directory load-file-name)))
(require 'ert)
(require 'use-proxy)
(ert-deftest use-proxy-test-toggle-proxies-global ()
(dolist (repeat '(on off))
(if (assoc "no_proxy" url-proxy-services)
(progn
(use-proxy-toggle-proxies-global)
(should (equal nil (assoc "no_proxy" url-proxy-services))))
(progn
(use-proxy-toggle-proxies-global)
(should (not (equal nil (assoc "no_proxy" url-proxy-services))))))))
(ert-deftest use-proxy-test-toggle-proto-proxy ()
(dolist (proto use-proxy--available-protocols)
(dolist (repeat '(on off))
(if (equal nil (assoc proto url-proxy-services))
(progn
(use-proxy-toggle-proto-proxy proto)
(should (equal (cons proto (use-proxy--get-custom-proxy-var-by-proto proto))
(assoc proto url-proxy-services))))
(progn
(use-proxy-toggle-proto-proxy proto)
(should (equal nil (assoc proto url-proxy-services))))))))
(ert-deftest use-proxy-test-toggle-all-proxies ()
(dolist (repeat '(on off))
(if (equal nil url-proxy-services)
(progn
(use-proxy-toggle-all-proxies)
(dolist (proto use-proxy--available-protocols)
(should (equal (cons proto (use-proxy--get-custom-proxy-var-by-proto proto))
(assoc proto url-proxy-services))))
(should (equal (cons "no_proxy" use-proxy-no-proxy)
(assoc "no_proxy" url-proxy-services)))))
(if (not (equal nil url-proxy-services))
(progn
(use-proxy-toggle-all-proxies)
(should (equal nil url-proxy-services))))))
(ert-deftest use-proxy-test-with-custom-proxies ()
(use-proxy-with-custom-proxies use-proxy--available-protocols
(dolist (proto use-proxy--available-protocols)
(should (equal (use-proxy--get-custom-proxy-var-by-proto proto)
(cdr (assoc proto url-proxy-services)))))))
(ert-deftest use-proxy-test-with-specified-proxies ()
(let ((protos-assoc '(("http" . "localhost:8001")
("https" . "localhost:8002"))))
(should (equal protos-assoc
(use-proxy-with-specified-proxies protos-assoc url-proxy-services)))))