forked from rexim/org-cliplink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
curl-integration-tests.el
89 lines (79 loc) · 3.2 KB
/
curl-integration-tests.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
(require 'ert)
(add-to-list 'load-path ".")
(load "org-cliplink.el")
(setq org-cliplink-transport-implementation 'curl)
(setq org-cliplink-curl-transport-arguments '("--insecure"))
(ert-deftest org-cliplink-without-title--http ()
(let ((url "http://127.0.0.1:8001/without-title.html")
(expected-outcome "[[http://127.0.0.1:8001/without-title.html]]")
(timeout 5))
(with-temp-buffer
(kill-new url)
(org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-deftest org-cliplink-simple-title--http ()
(let ((url "http://127.0.0.1:8001/http.html")
(expected-outcome "[[http://127.0.0.1:8001/http.html][Hello World]]")
(timeout 5))
(with-temp-buffer
(kill-new url)
(org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-deftest org-cliplink-long-title-with-custom-transformer--http ()
(let ((url "http://127.0.0.1:8001/long-title.html")
(expected-outcome "[[http://127.0.0.1:8001/long-title.html][long title]]")
(timeout 1)
(custom-org-cliplink
(lambda ()
(org-cliplink-insert-transformed-title
(org-cliplink-clipboard-content)
(lambda (url title)
(org-cliplink-org-mode-link-transformer
url
(replace-regexp-in-string "\\(very \\)+\\([[:alpha:][:space:]]+\\)" "\\2" title)))))))
(with-temp-buffer
(kill-new url)
(funcall custom-org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-deftest org-cliplink-escape-title--http ()
(let ((url "http://127.0.0.1:8001/html4-escaping.html")
(expected-outcome "[[http://127.0.0.1:8001/html4-escaping.html][&{Hello} '{World} α ]]")
(timeout 5))
(with-temp-buffer
(kill-new url)
(org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-deftest org-cliplink-simple-title--https ()
(let ((url "https://127.0.0.1:4443/http.html")
(expected-outcome "[[https://127.0.0.1:4443/http.html][Hello World]]")
(timeout 5))
(with-temp-buffer
(kill-new url)
(org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-deftest org-cliplink-simple-title--http-with-basic-auth ()
(let ((url "http://127.0.0.1:8003/http.html")
(expected-outcome "[[http://127.0.0.1:8003/http.html][Hello World]]")
(timeout 5)
(org-cliplink-secrets-path "./test-data/secrets/org-cliplink-basic-auth-it.el"))
(with-temp-buffer
(kill-new url)
(org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-deftest org-cliplink-simple-title--https-with-basic-auth ()
(let ((url "https://127.0.0.1:4445/http.html")
(expected-outcome "[[https://127.0.0.1:4445/http.html][Hello World]]")
(timeout 5)
(org-cliplink-secrets-path "./test-data/secrets/org-cliplink-basic-auth-it.el"))
(with-temp-buffer
(kill-new url)
(org-cliplink)
(sleep-for timeout)
(should (equal (buffer-string) expected-outcome)))))
(ert-run-tests-batch-and-exit)