-
Notifications
You must be signed in to change notification settings - Fork 74
/
git-link-test.el
91 lines (62 loc) · 4.34 KB
/
git-link-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
91
;; Tests for git-link
(require 'ert)
(require 'git-link)
(ert-deftest git-link--parse-remote-test ()
(should (equal '("foo" "")
(git-link--parse-remote "foo")))
(should (equal '("github.com" "")
(git-link--parse-remote "https://github.com")))
(should (equal '("github.com" "/")
(git-link--parse-remote "https://github.com/")))
(should (equal '("github.com" "sshaw_/selfie_formatter")
(git-link--parse-remote "[email protected]:sshaw_/selfie_formatter.git")))
(should (equal '("github.com" "ruby/ruby")
(git-link--parse-remote "https://github.com/ruby/ruby.git")))
(should (equal '("github.com" "sshaw/copy-as-format")
(git-link--parse-remote "https://github.com:9999/sshaw/copy-as-format.git")))
(should (equal '("github.com" "ScreenStaring/Some-Thing")
(git-link--parse-remote "[email protected]:ScreenStaring/Some-Thing.git")))
(should (equal '("orgmode.org" "org-mode")
(git-link--parse-remote "https://orgmode.org/org-mode.git")))
(should (equal '("gitlab.com" "weshmashian/emacs.d")
(git-link--parse-remote "https://gitlab.com/weshmashian/emacs.d")))
(should (equal '("codeberg.org" "takeonrules/emacs.d")
(git-link--parse-remote "https://codeberg.org/takeonrules/emacs.d")))
(should (equal '("foo-bar.github.com" "sshaw/foo/x")
(git-link--parse-remote "https://user:[email protected]/sshaw/foo/x.git")))
(should (equal '("msazure.visualstudio.com" "project/_git/repo")
(git-link--parse-remote "[email protected]:v3/msazure/project/repo")))
(should (equal '("msazure.visualstudio.com" "DefaultCollection/project/_git/repo")
(git-link--parse-remote "https://msazure.visualstudio.com/DefaultCollection/project/_git/repo")))
(should (equal '("dev.azure.com" "r-darwish/project/_git/repo")
(git-link--parse-remote "[email protected]:v3/r-darwish/project/repo")))
(should (equal '("dev.azure.com" "r-darwish/project/_git/repo")
(git-link--parse-remote "https://[email protected]/r-darwish/project/_git/repo")))
(should (equal '("git.sv.gnu.org" "emacs")
(git-link--parse-remote "git://git.sv.gnu.org/emacs.git")))
(should (equal '("git.savannah.gnu.org" "emacs")
(git-link--parse-remote "https://git.savannah.gnu.org/git/emacs.git")))
(should (equal '("git.savannah.gnu.org" "emacs")
(git-link--parse-remote "ssh://git.savannah.gnu.org/srv/git/emacs.git")))
(should (equal '("git.savannah.gnu.org" "emacs")
(git-link--parse-remote "git://git.savannah.gnu.org/emacs.git")))
(should (equal '("us-west-2.console.aws.amazon.com" "codesuite/codecommit/repositories/TestRepo")
(git-link--parse-remote "ssh://git-codecommit.us-west-2.amazonaws.com/v1/repos/TestRepo")))
(should (equal '("go.googlesource.com" "go")
(git-link--parse-remote "https://go.googlesource.com/go")))
(should (equal '("bitbucket.org" "atlassianlabs/atlascode")
(git-link--parse-remote "https://bitbucket.org/atlassianlabs/atlascode.git")))
(should (equal '("bitbucket.org" "atlassianlabs/atlascode")
(git-link--parse-remote "ssh://bitbucket.org:atlassianlabs/atlascode.git"))))
(ert-deftest git-link-bitbucket ()
(should (equal "https://bitbucket.org/atlassian/atlascode/annotate/a-commit-hash/README.md#README.md-1"
(git-link-bitbucket "bitbucket.org" "atlassian/atlascode" "README.md" "_branch" "a-commit-hash" 1 nil)))
(should (equal "https://bitbucket.org/atlassian/atlascode/annotate/a-commit-hash/README.md#README.md-1:33"
(git-link-bitbucket "bitbucket.org" "atlassian/atlascode" "README.md" "_branch" "a-commit-hash" 1 33)))
(should (equal "https://bitbucket.org/atlassian/atlascode/src/a-commit-hash/.gitignore#.gitignore-1:33"
(git-link-bitbucket "bitbucket.org" "atlassian/atlascode" ".gitignore" "_branch" "a-commit-hash" 1 33))))
(ert-deftest git-link--should-render-via-bitbucket-annotate ()
(should (equal "annotate"
(git-link--should-render-via-bitbucket-annotate "README.md")))
(should (equal "src"
(git-link--should-render-via-bitbucket-annotate "a-cool-new-file.txt"))))