mirror of
https://github.com/NinjaTrappeur/my-repo-pins.git
synced 2024-06-08 14:20:35 +02:00
Github fetcher: implement response parser
This commit is contained in:
parent
78cd7553d2
commit
09c5099488
14
h-tests.el
14
h-tests.el
|
@ -196,5 +196,19 @@ For reference: a empty test root looks like this:
|
|||
((results (h--get-code-root-projects "/does/not/exist")))
|
||||
(should (seq-empty-p results))))
|
||||
|
||||
|
||||
;; Test Fetchers
|
||||
;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; Github
|
||||
|
||||
(ert-deftest h--tests-fetch-github-parse-response ()
|
||||
"Test h--tests-fetch-github-parse-response with a fixture."
|
||||
(with-temp-buffer
|
||||
(insert-file-contents "./tests/fixtures/github-repo-query-response.json")
|
||||
(should (equal (h--fetch-github-parse-response (current-buffer))
|
||||
'((ssh . "git@github.com:NinjaTrappeur/h.el.git")
|
||||
(https . "https://github.com/NinjaTrappeur/h.el.git"))))))
|
||||
|
||||
(provide 'h-tests)
|
||||
;;; h-tests.el ends here
|
||||
|
|
7
h.el
7
h.el
|
@ -74,7 +74,12 @@ Errors out if we can't find it."
|
|||
"Parse the RESPONSE-BUFFER containing a GET response from the GitHub API.
|
||||
|
||||
Parsing a response from a GET https://api.github.com/repos/user/repo request."
|
||||
response-buffer)
|
||||
(progn (set-buffer response-buffer)
|
||||
(goto-char 0)
|
||||
(let* ((parsed-buffer (json-parse-buffer))
|
||||
(ssh-url (gethash "ssh_url" parsed-buffer))
|
||||
(https-url (gethash "clone_url" parsed-buffer)))
|
||||
`((ssh . ,ssh-url) (https . ,https-url)))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Internal: code-root management functions
|
||||
|
|
109
tests/fixtures/github-repo-query-response.json
vendored
Normal file
109
tests/fixtures/github-repo-query-response.json
vendored
Normal file
|
@ -0,0 +1,109 @@
|
|||
{
|
||||
"id": 476823023,
|
||||
"node_id": "R_kgDOHGu97w",
|
||||
"name": "h.el",
|
||||
"full_name": "NinjaTrappeur/h.el",
|
||||
"private": false,
|
||||
"owner": {
|
||||
"login": "NinjaTrappeur",
|
||||
"id": 1219785,
|
||||
"node_id": "MDQ6VXNlcjEyMTk3ODU=",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1219785?v=4",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/NinjaTrappeur",
|
||||
"html_url": "https://github.com/NinjaTrappeur",
|
||||
"followers_url": "https://api.github.com/users/NinjaTrappeur/followers",
|
||||
"following_url": "https://api.github.com/users/NinjaTrappeur/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/NinjaTrappeur/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/NinjaTrappeur/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/NinjaTrappeur/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/NinjaTrappeur/orgs",
|
||||
"repos_url": "https://api.github.com/users/NinjaTrappeur/repos",
|
||||
"events_url": "https://api.github.com/users/NinjaTrappeur/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/NinjaTrappeur/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
},
|
||||
"html_url": "https://github.com/NinjaTrappeur/h.el",
|
||||
"description": "Emacs project manager and remote git checkout",
|
||||
"fork": false,
|
||||
"url": "https://api.github.com/repos/NinjaTrappeur/h.el",
|
||||
"forks_url": "https://api.github.com/repos/NinjaTrappeur/h.el/forks",
|
||||
"keys_url": "https://api.github.com/repos/NinjaTrappeur/h.el/keys{/key_id}",
|
||||
"collaborators_url": "https://api.github.com/repos/NinjaTrappeur/h.el/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.github.com/repos/NinjaTrappeur/h.el/teams",
|
||||
"hooks_url": "https://api.github.com/repos/NinjaTrappeur/h.el/hooks",
|
||||
"issue_events_url": "https://api.github.com/repos/NinjaTrappeur/h.el/issues/events{/number}",
|
||||
"events_url": "https://api.github.com/repos/NinjaTrappeur/h.el/events",
|
||||
"assignees_url": "https://api.github.com/repos/NinjaTrappeur/h.el/assignees{/user}",
|
||||
"branches_url": "https://api.github.com/repos/NinjaTrappeur/h.el/branches{/branch}",
|
||||
"tags_url": "https://api.github.com/repos/NinjaTrappeur/h.el/tags",
|
||||
"blobs_url": "https://api.github.com/repos/NinjaTrappeur/h.el/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.github.com/repos/NinjaTrappeur/h.el/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.github.com/repos/NinjaTrappeur/h.el/git/refs{/sha}",
|
||||
"trees_url": "https://api.github.com/repos/NinjaTrappeur/h.el/git/trees{/sha}",
|
||||
"statuses_url": "https://api.github.com/repos/NinjaTrappeur/h.el/statuses/{sha}",
|
||||
"languages_url": "https://api.github.com/repos/NinjaTrappeur/h.el/languages",
|
||||
"stargazers_url": "https://api.github.com/repos/NinjaTrappeur/h.el/stargazers",
|
||||
"contributors_url": "https://api.github.com/repos/NinjaTrappeur/h.el/contributors",
|
||||
"subscribers_url": "https://api.github.com/repos/NinjaTrappeur/h.el/subscribers",
|
||||
"subscription_url": "https://api.github.com/repos/NinjaTrappeur/h.el/subscription",
|
||||
"commits_url": "https://api.github.com/repos/NinjaTrappeur/h.el/commits{/sha}",
|
||||
"git_commits_url": "https://api.github.com/repos/NinjaTrappeur/h.el/git/commits{/sha}",
|
||||
"comments_url": "https://api.github.com/repos/NinjaTrappeur/h.el/comments{/number}",
|
||||
"issue_comment_url": "https://api.github.com/repos/NinjaTrappeur/h.el/issues/comments{/number}",
|
||||
"contents_url": "https://api.github.com/repos/NinjaTrappeur/h.el/contents/{+path}",
|
||||
"compare_url": "https://api.github.com/repos/NinjaTrappeur/h.el/compare/{base}...{head}",
|
||||
"merges_url": "https://api.github.com/repos/NinjaTrappeur/h.el/merges",
|
||||
"archive_url": "https://api.github.com/repos/NinjaTrappeur/h.el/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.github.com/repos/NinjaTrappeur/h.el/downloads",
|
||||
"issues_url": "https://api.github.com/repos/NinjaTrappeur/h.el/issues{/number}",
|
||||
"pulls_url": "https://api.github.com/repos/NinjaTrappeur/h.el/pulls{/number}",
|
||||
"milestones_url": "https://api.github.com/repos/NinjaTrappeur/h.el/milestones{/number}",
|
||||
"notifications_url": "https://api.github.com/repos/NinjaTrappeur/h.el/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.github.com/repos/NinjaTrappeur/h.el/labels{/name}",
|
||||
"releases_url": "https://api.github.com/repos/NinjaTrappeur/h.el/releases{/id}",
|
||||
"deployments_url": "https://api.github.com/repos/NinjaTrappeur/h.el/deployments",
|
||||
"created_at": "2022-04-01T18:06:46Z",
|
||||
"updated_at": "2022-04-01T18:08:16Z",
|
||||
"pushed_at": "2022-04-06T17:54:48Z",
|
||||
"git_url": "git://github.com/NinjaTrappeur/h.el.git",
|
||||
"ssh_url": "git@github.com:NinjaTrappeur/h.el.git",
|
||||
"clone_url": "https://github.com/NinjaTrappeur/h.el.git",
|
||||
"svn_url": "https://github.com/NinjaTrappeur/h.el",
|
||||
"homepage": null,
|
||||
"size": 45,
|
||||
"stargazers_count": 0,
|
||||
"watchers_count": 0,
|
||||
"language": "Emacs Lisp",
|
||||
"has_issues": true,
|
||||
"has_projects": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"forks_count": 0,
|
||||
"mirror_url": null,
|
||||
"archived": false,
|
||||
"disabled": false,
|
||||
"open_issues_count": 0,
|
||||
"license": {
|
||||
"key": "gpl-3.0",
|
||||
"name": "GNU General Public License v3.0",
|
||||
"spdx_id": "GPL-3.0",
|
||||
"url": "https://api.github.com/licenses/gpl-3.0",
|
||||
"node_id": "MDc6TGljZW5zZTk="
|
||||
},
|
||||
"allow_forking": true,
|
||||
"is_template": false,
|
||||
"topics": [
|
||||
|
||||
],
|
||||
"visibility": "public",
|
||||
"forks": 0,
|
||||
"open_issues": 0,
|
||||
"watchers": 0,
|
||||
"default_branch": "master",
|
||||
"temp_clone_token": null,
|
||||
"network_count": 0,
|
||||
"subscribers_count": 1
|
||||
}
|
Loading…
Reference in a new issue