{"action":"created","comment":{"url":"https://api.github.com/repos/kbaba1001/duct-sample/pulls/comments/167433887","pull_request_review_id":95654671,"id":167433887,"diff_hunk":"@@ -0,0 +1,56 @@\n+(ns duct-sample.boundary.users-test\n+  (:require [clojure.test :refer :all]\n+            [clojure.java.jdbc :as jdbc]\n+            [integrant.core :as ig]\n+            [duct-sample.boundary.users :as users]\n+            [fipp.edn :refer (pprint) :rename {pprint fipp}])\n+  (:use [duct.database.sql]))\n+\n+(def db-spec \"jdbc:postgresql://localhost:5432/duct-sample-test?user=postgres\")\n+\n+; これでSQLを実際のデータベースで実行できる。\n+; use ではなく require だと -> がうまく出来なかった\n+(def db (->Boundary db-spec))\n+\n+(defn create-data []\n+  (do\n+    (println \"create-data\")\n+    (users/create-user db {:name \"kbaba\" :email \"kbaba@example.com\"})))\n+\n+(defn delete-data []\n+  (do\n+    (println \"delete-test\")\n+    (jdbc/delete! db-spec :users [])))\n+\n+(defn my-test-fixture [f]\n+        (create-data)\n+        (f)\n+        (delete-data))\n+\n+(use-fixtures :once my-test-fixture)\n+\n+; -----------------------------\n+\n+(deftest test-get-users\n+  (testing \"get users\"\n+    (let [user-data (first (users/get-users db))]\n+      (are [expected actual] (= expected actual)\n+        \"kbaba@example.com\" (:email user-data)\n+        \"kbaba\" (:name user-data)))))\n+\n+(deftest test-create-and-get-user\n+  (testing \"create and get user\"\n+    (let [user-id (:id (first (users/create-user db {:name \"user1\" :email \"user1@example.com\"})))\n+          user-data (first (users/get-user db user-id))]\n+      (are [expected actual] (= expected actual)\n+        \"user1\" (:name user-data)\n+        \"user1@example.com\" (:email user-data)))))\n+\n+(deftest test-update-user\n+  (testing \"update user\"\n+    (let [user-id (:id (first (users/create-user db {:name \"user1\" :email \"user1@example.com\"})))\n+          updated-user-id (:id (first (users/update-user db user-id {:name \"user2\" :email \"user2@example.com\"})))\n+          user-data (first (users/get-user db user-id))]\n+      (are [expected actual] (= expected actual)\n+        \"user2\" (:name user-data)\n+        \"user2@example.com\" (:email user-data)))))","path":"test/duct_sample/boundary/users_test.clj","position":56,"original_position":56,"commit_id":"2fa4278f6c32cbe66fa783d7ba9605a407493ae4","original_commit_id":"2fa4278f6c32cbe66fa783d7ba9605a407493ae4","user":{"login":"kbaba1001","id":1624680,"avatar_url":"https://avatars3.githubusercontent.com/u/1624680?v=4","gravatar_id":"","url":"https://api.github.com/users/kbaba1001","html_url":"https://github.com/kbaba1001","followers_url":"https://api.github.com/users/kbaba1001/followers","following_url":"https://api.github.com/users/kbaba1001/following{/other_user}","gists_url":"https://api.github.com/users/kbaba1001/gists{/gist_id}","starred_url":"https://api.github.com/users/kbaba1001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbaba1001/subscriptions","organizations_url":"https://api.github.com/users/kbaba1001/orgs","repos_url":"https://api.github.com/users/kbaba1001/repos","events_url":"https://api.github.com/users/kbaba1001/events{/privacy}","received_events_url":"https://api.github.com/users/kbaba1001/received_events","type":"User","site_admin":false},"body":"SQLのテストを書くことに違和感が有るなら、PostgreSQLの単体テストを作るという手も有るのか。\r\n[pgTAP](http://pgtap.org/documentation.html) というのでSQLの単体テストができるっぽい。\r\n\r\nhugSQLなら SQL と Clojure を分離できるわけで、このような方法はありかもしれない。","created_at":"2018-02-11T12:55:07Z","updated_at":"2018-02-11T12:55:08Z","html_url":"https://github.com/kbaba1001/duct-sample/pull/3#discussion_r167433887","pull_request_url":"https://api.github.com/repos/kbaba1001/duct-sample/pulls/3","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/kbaba1001/duct-sample/pulls/comments/167433887"},"html":{"href":"https://github.com/kbaba1001/duct-sample/pull/3#discussion_r167433887"},"pull_request":{"href":"https://api.github.com/repos/kbaba1001/duct-sample/pulls/3"}},"in_reply_to_id":167433477},"pull_request":{"url":"https://api.github.com/repos/kbaba1001/duct-sample/pulls/3","id":168400819,"html_url":"https://github.com/kbaba1001/duct-sample/pull/3","diff_url":"https://github.com/kbaba1001/duct-sample/pull/3.diff","patch_url":"https://github.com/kbaba1001/duct-sample/pull/3.patch","issue_url":"https://api.github.com/repos/kbaba1001/duct-sample/issues/3","number":3,"state":"open","locked":false,"title":"Add test","user":{"login":"kbaba1001","id":1624680,"avatar_url":"https://avatars3.githubusercontent.com/u/1624680?v=4","gravatar_id":"","url":"https://api.github.com/users/kbaba1001","html_url":"https://github.com/kbaba1001","followers_url":"https://api.github.com/users/kbaba1001/followers","following_url":"https://api.github.com/users/kbaba1001/following{/other_user}","gists_url":"https://api.github.com/users/kbaba1001/gists{/gist_id}","starred_url":"https://api.github.com/users/kbaba1001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbaba1001/subscriptions","organizations_url":"https://api.github.com/users/kbaba1001/orgs","repos_url":"https://api.github.com/users/kbaba1001/repos","events_url":"https://api.github.com/users/kbaba1001/events{/privacy}","received_events_url":"https://api.github.com/users/kbaba1001/received_events","type":"User","site_admin":false},"body":"- [x] test用のデータベースを用意する\r\n- [x] 同じマイグレーションでtest用とdev用のDBを作成できるようにする (ragtime使用)\r\n- [x] boundaryのテストを作成する\r\n- [x] clojure.test で startup と closeup でテストデータ投入と削除を行う\r\n- [x] `duct-sample.boundary.users-test` をちゃんと書く\r\n- [ ] eftest がパラレルで実行されているかもしれないので、ひとまずシングル実行にする\r\n- [ ] handler のテストを書く\r\n- [ ] [kerodon](https://github.com/xeqi/kerodon) を使ってみる","created_at":"2018-02-10T12:56:53Z","updated_at":"2018-02-11T12:55:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"48434da35176b3f4d4341c491ca4e3c39a1dbae3","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":833207730,"url":"https://api.github.com/repos/kbaba1001/duct-sample/labels/WIP","name":"WIP","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/kbaba1001/duct-sample/pulls/3/commits","review_comments_url":"https://api.github.com/repos/kbaba1001/duct-sample/pulls/3/comments","review_comment_url":"https://api.github.com/repos/kbaba1001/duct-sample/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kbaba1001/duct-sample/issues/3/comments","statuses_url":"https://api.github.com/repos/kbaba1001/duct-sample/statuses/2fa4278f6c32cbe66fa783d7ba9605a407493ae4","head":{"label":"kbaba1001:add-test","ref":"add-test","sha":"2fa4278f6c32cbe66fa783d7ba9605a407493ae4","user":{"login":"kbaba1001","id":1624680,"avatar_url":"https://avatars3.githubusercontent.com/u/1624680?v=4","gravatar_id":"","url":"https://api.github.com/users/kbaba1001","html_url":"https://github.com/kbaba1001","followers_url":"https://api.github.com/users/kbaba1001/followers","following_url":"https://api.github.com/users/kbaba1001/following{/other_user}","gists_url":"https://api.github.com/users/kbaba1001/gists{/gist_id}","starred_url":"https://api.github.com/users/kbaba1001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbaba1001/subscriptions","organizations_url":"https://api.github.com/users/kbaba1001/orgs","repos_url":"https://api.github.com/users/kbaba1001/repos","events_url":"https://api.github.com/users/kbaba1001/events{/privacy}","received_events_url":"https://api.github.com/users/kbaba1001/received_events","type":"User","site_admin":false},"repo":{"id":116373111,"name":"duct-sample","full_name":"kbaba1001/duct-sample","owner":{"login":"kbaba1001","id":1624680,"avatar_url":"https://avatars3.githubusercontent.com/u/1624680?v=4","gravatar_id":"","url":"https://api.github.com/users/kbaba1001","html_url":"https://github.com/kbaba1001","followers_url":"https://api.github.com/users/kbaba1001/followers","following_url":"https://api.github.com/users/kbaba1001/following{/other_user}","gists_url":"https://api.github.com/users/kbaba1001/gists{/gist_id}","starred_url":"https://api.github.com/users/kbaba1001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbaba1001/subscriptions","organizations_url":"https://api.github.com/users/kbaba1001/orgs","repos_url":"https://api.github.com/users/kbaba1001/repos","events_url":"https://api.github.com/users/kbaba1001/events{/privacy}","received_events_url":"https://api.github.com/users/kbaba1001/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kbaba1001/duct-sample","description":"ductを勉強するためのリポジトリ","fork":false,"url":"https://api.github.com/repos/kbaba1001/duct-sample","forks_url":"https://api.github.com/repos/kbaba1001/duct-sample/forks","keys_url":"https://api.github.com/repos/kbaba1001/duct-sample/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kbaba1001/duct-sample/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kbaba1001/duct-sample/teams","hooks_url":"https://api.github.com/repos/kbaba1001/duct-sample/hooks","issue_events_url":"https://api.github.com/repos/kbaba1001/duct-sample/issues/events{/number}","events_url":"https://api.github.com/repos/kbaba1001/duct-sample/events","assignees_url":"https://api.github.com/repos/kbaba1001/duct-sample/assignees{/user}","branches_url":"https://api.github.com/repos/kbaba1001/duct-sample/branches{/branch}","tags_url":"https://api.github.com/repos/kbaba1001/duct-sample/tags","blobs_url":"https://api.github.com/repos/kbaba1001/duct-sample/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kbaba1001/duct-sample/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kbaba1001/duct-sample/git/refs{/sha}","trees_url":"https://api.github.com/repos/kbaba1001/duct-sample/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kbaba1001/duct-sample/statuses/{sha}","languages_url":"https://api.github.com/repos/kbaba1001/duct-sample/languages","stargazers_url":"https://api.github.com/repos/kbaba1001/duct-sample/stargazers","contributors_url":"https://api.github.com/repos/kbaba1001/duct-sample/contributors","subscribers_url":"https://api.github.com/repos/kbaba1001/duct-sample/subscribers","subscription_url":"https://api.github.com/repos/kbaba1001/duct-sample/subscription","commits_url":"https://api.github.com/repos/kbaba1001/duct-sample/commits{/sha}","git_commits_url":"https://api.github.com/repos/kbaba1001/duct-sample/git/commits{/sha}","comments_url":"https://api.github.com/repos/kbaba1001/duct-sample/comments{/number}","issue_comment_url":"https://api.github.com/repos/kbaba1001/duct-sample/issues/comments{/number}","contents_url":"https://api.github.com/repos/kbaba1001/duct-sample/contents/{+path}","compare_url":"https://api.github.com/repos/kbaba1001/duct-sample/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kbaba1001/duct-sample/merges","archive_url":"https://api.github.com/repos/kbaba1001/duct-sample/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kbaba1001/duct-sample/downloads","issues_url":"https://api.github.com/repos/kbaba1001/duct-sample/issues{/number}","pulls_url":"https://api.github.com/repos/kbaba1001/duct-sample/pulls{/number}","milestones_url":"https://api.github.com/repos/kbaba1001/duct-sample/milestones{/number}","notifications_url":"https://api.github.com/repos/kbaba1001/duct-sample/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kbaba1001/duct-sample/labels{/name}","releases_url":"https://api.github.com/repos/kbaba1001/duct-sample/releases{/id}","deployments_url":"https://api.github.com/repos/kbaba1001/duct-sample/deployments","created_at":"2018-01-05T10:27:55Z","updated_at":"2018-02-10T13:38:22Z","pushed_at":"2018-02-11T12:34:37Z","git_url":"git://github.com/kbaba1001/duct-sample.git","ssh_url":"git@github.com:kbaba1001/duct-sample.git","clone_url":"https://github.com/kbaba1001/duct-sample.git","svn_url":"https://github.com/kbaba1001/duct-sample","homepage":"","size":14,"stargazers_count":0,"watchers_count":0,"language":"Clojure","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"kbaba1001:master","ref":"master","sha":"b6441c654813e12c1082ce22d8e09cc7cc766155","user":{"login":"kbaba1001","id":1624680,"avatar_url":"https://avatars3.githubusercontent.com/u/1624680?v=4","gravatar_id":"","url":"https://api.github.com/users/kbaba1001","html_url":"https://github.com/kbaba1001","followers_url":"https://api.github.com/users/kbaba1001/followers","following_url":"https://api.github.com/users/kbaba1001/following{/other_user}","gists_url":"https://api.github.com/users/kbaba1001/gists{/gist_id}","starred_url":"https://api.github.com/users/kbaba1001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbaba1001/subscriptions","organizations_url":"https://api.github.com/users/kbaba1001/orgs","repos_url":"https://api.github.com/users/kbaba1001/repos","events_url":"https://api.github.com/users/kbaba1001/events{/privacy}","received_events_url":"https://api.github.com/users/kbaba1001/received_events","type":"User","site_admin":false},"repo":{"id":116373111,"name":"duct-sample","full_name":"kbaba1001/duct-sample","owner":{"login":"kbaba1001","id":1624680,"avatar_url":"https://avatars3.githubusercontent.com/u/1624680?v=4","gravatar_id":"","url":"https://api.github.com/users/kbaba1001","html_url":"https://github.com/kbaba1001","followers_url":"https://api.github.com/users/kbaba1001/followers","following_url":"https://api.github.com/users/kbaba1001/following{/other_user}","gists_url":"https://api.github.com/users/kbaba1001/gists{/gist_id}","starred_url":"https://api.github.com/users/kbaba1001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbaba1001/subscriptions","organizations_url":"https://api.github.com/users/kbaba1001/orgs","repos_url":"https://api.github.com/users/kbaba1001/repos","events_url":"https://api.github.com/users/kbaba1001/events{/privacy}","received_events_url":"https://api.github.com/users/kbaba1001/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kbaba1001/duct-sample","description":"ductを勉強するためのリポジトリ","fork":false,"url":"https://api.github.com/repos/kbaba1001/duct-sample","forks_url":"https://api.github.com/repos/kbaba1001/duct-sample/forks","keys_url":"https://api.github.com/repos/kbaba1001/duct-sample/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kbaba1001/duct-sample/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kbaba1001/duct-sample/teams","hooks_url":"https://api.github.com/repos/kbaba1001/duct-sample/hooks","issue_events_url":"https://api.github.com/repos/kbaba1001/duct-sample/issues/events{/number}","events_url":"https://api.github.com/repos/kbaba1001/duct-sample/events","assignees_url":"https://api.github.com/repos/kbaba1001/duct-sample/assignees{/user}","branches_url":"https://api.github.com/repos/kbaba1001/duct-sample/branches{/branch}","tags_url":"https://api.github.com/repos/kbaba1001/duct-sample/tags","blobs_url":"https://api.github.com/repos/kbaba1001/duct-sample/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kbaba1001/duct-sample/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kbaba1001/duct-sample/git/refs{/sha}","trees_url":"https://api.github.com/repos/kbaba1001/duct-sample/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kbaba1001/duct-sample/statuses/{sha}","languages_url":"https://api.github.com/repos/kbaba1001/duct-sample/languages","stargazers_url":"https://api.github.com/repos/kbaba1001/duct-sample/stargazers","contributors_url":"https://api.github.com/repos/kbaba1001/duct-sample/contributors","subscribers_url":"https://api.github.com/repos/kbaba1001/duct-sample/subscribers","subscription_url":"https://api.github.com/repos/kbaba1001/duct-sample/subscription","commits_url":"https://api.github.com/repos/kbaba1001/duct-sample/commits{/sha}","git_commits_url":"https://api.github.com/repos/kbaba1001/duct-sample/git/commits{/sha}","comments_url":"https://api.github.com/repos/kbaba1001/duct-sample/comments{/number}","issue_comment_url":"https://api.github.com/repos/kbaba1001/duct-sample/issues/comments{/number}","contents_url":"https://api.github.com/repos/kbaba1001/duct-sample/contents/{+path}","compare_url":"https://api.github.com/repos/kbaba1001/duct-sample/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kbaba1001/duct-sample/merges","archive_url":"https://api.github.com/repos/kbaba1001/duct-sample/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kbaba1001/duct-sample/downloads","issues_url":"https://api.github.com/repos/kbaba1001/duct-sample/issues{/number}","pulls_url":"https://api.github.com/repos/kbaba1001/duct-sample/pulls{/number}","milestones_url":"https://api.github.com/repos/kbaba1001/duct-sample/milestones{/number}","notifications_url":"https://api.github.com/repos/kbaba1001/duct-sample/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kbaba1001/duct-sample/labels{/name}","releases_url":"https://api.github.com/repos/kbaba1001/duct-sample/releases{/id}","deployments_url":"https://api.github.com/repos/kbaba1001/duct-sample/deployments","created_at":"2018-01-05T10:27:55Z","updated_at":"2018-02-10T13:38:22Z","pushed_at":"2018-02-11T12:34:37Z","git_url":"git://github.com/kbaba1001/duct-sample.git","ssh_url":"git@github.com:kbaba1001/duct-sample.git","clone_url":"https://github.com/kbaba1001/duct-sample.git","svn_url":"https://github.com/kbaba1001/duct-sample","homepage":"","size":14,"stargazers_count":0,"watchers_count":0,"language":"Clojure","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":null,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kbaba1001/duct-sample/pulls/3"},"html":{"href":"https://github.com/kbaba1001/duct-sample/pull/3"},"issue":{"href":"https://api.github.com/repos/kbaba1001/duct-sample/issues/3"},"comments":{"href":"https://api.github.com/repos/kbaba1001/duct-sample/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/kbaba1001/duct-sample/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/kbaba1001/duct-sample/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kbaba1001/duct-sample/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/kbaba1001/duct-sample/statuses/2fa4278f6c32cbe66fa783d7ba9605a407493ae4"}},"author_association":"OWNER"}}
{"actor":{"display_login":"kbaba1001"}}