{"action":"created","comment":{"url":"https://api.github.com/repos/ZolaApp/zola-api/pulls/comments/185315444","pull_request_review_id":116676010,"id":185315444,"diff_hunk":"@@ -0,0 +1,59 @@\n+import resetDatabase from '@tests/resetDatabase'\n+import database from '@database/index'\n+import { createToken, retrieveToken, validateToken } from './index'\n+\n+describe('The Token model helpers', () => {\n+  beforeAll(async done => {\n+    await resetDatabase()\n+    await database.migrate.latest()\n+    done()\n+  })\n+\n+  it(\"should return errors if the user doesn't exist\", async done => {\n+    const { token, errors } = await createToken()\n+    const expected = { field: 'user', message: 'User should be defined' }\n+\n+    expect(token).toEqual(undefined)\n+    expect(errors).toContainEqual(expected)\n+    done()\n+  })\n+\n+  it('should add a token to the database and return it', async done => {\n+    await database.seed.run()\n+\n+    const testUser = await database('users').where({ id: 1 })\n+    const countBefore = await database('tokens').count()\n+    const { token } = await createToken(testUser)\n+    const countAfter = await database('users').count()\n+\n+    expect(countBefore[0].count).toEqual('0')\n+    expect(countAfter[0].count).toEqual('1')\n+    expect(token).toMatchObject({\n+      id: 1,\n+      userId: 1\n+    })\n+    done()\n+  })\n+\n+  it('should be able to retreive an existing token', async done => {\n+    await database.seed.run()\n+\n+    const testUser = await database('users').where({ id: 1 })\n+    const { token } = await createToken(testUser)\n+    const receivedToken = await retrieveToken(testUser)\n+\n+    expect(receivedToken).toEqual(token)\n+    done()\n+  })\n+\n+  it('should be able to validate an existing token', async done => {\n+    await database.seed.run()\n+\n+    const testUser = await database('users').where({ id: 1 })\n+    const { token } = await createToken(testUser)\n+    const isValidated = await validateToken(token)","path":"src/models/Token/integration.spec.js","position":54,"original_position":54,"commit_id":"c52ca24c5a2dd5c2b66701defa7eedd65a08c9b8","original_commit_id":"c52ca24c5a2dd5c2b66701defa7eedd65a08c9b8","user":{"login":"Tom-Bonnike","id":9154236,"avatar_url":"https://avatars2.githubusercontent.com/u/9154236?v=4","gravatar_id":"","url":"https://api.github.com/users/Tom-Bonnike","html_url":"https://github.com/Tom-Bonnike","followers_url":"https://api.github.com/users/Tom-Bonnike/followers","following_url":"https://api.github.com/users/Tom-Bonnike/following{/other_user}","gists_url":"https://api.github.com/users/Tom-Bonnike/gists{/gist_id}","starred_url":"https://api.github.com/users/Tom-Bonnike/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tom-Bonnike/subscriptions","organizations_url":"https://api.github.com/users/Tom-Bonnike/orgs","repos_url":"https://api.github.com/users/Tom-Bonnike/repos","events_url":"https://api.github.com/users/Tom-Bonnike/events{/privacy}","received_events_url":"https://api.github.com/users/Tom-Bonnike/received_events","type":"User","site_admin":false},"body":"You could test `validateToken` in another file if you had a seed for this specific test (you could create a `TEST_TOKEN` token so that you know its value without first creating it)","created_at":"2018-05-01T19:47:59Z","updated_at":"2018-05-01T19:49:23Z","html_url":"https://github.com/ZolaApp/zola-api/pull/68#discussion_r185315444","pull_request_url":"https://api.github.com/repos/ZolaApp/zola-api/pulls/68","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/ZolaApp/zola-api/pulls/comments/185315444"},"html":{"href":"https://github.com/ZolaApp/zola-api/pull/68#discussion_r185315444"},"pull_request":{"href":"https://api.github.com/repos/ZolaApp/zola-api/pulls/68"}}},"pull_request":{"url":"https://api.github.com/repos/ZolaApp/zola-api/pulls/68","id":185223397,"html_url":"https://github.com/ZolaApp/zola-api/pull/68","diff_url":"https://github.com/ZolaApp/zola-api/pull/68.diff","patch_url":"https://github.com/ZolaApp/zola-api/pull/68.patch","issue_url":"https://api.github.com/repos/ZolaApp/zola-api/issues/68","number":68,"state":"open","locked":false,"title":"Added tests for Token operations","user":{"login":"PauuloG","id":8963323,"avatar_url":"https://avatars3.githubusercontent.com/u/8963323?v=4","gravatar_id":"","url":"https://api.github.com/users/PauuloG","html_url":"https://github.com/PauuloG","followers_url":"https://api.github.com/users/PauuloG/followers","following_url":"https://api.github.com/users/PauuloG/following{/other_user}","gists_url":"https://api.github.com/users/PauuloG/gists{/gist_id}","starred_url":"https://api.github.com/users/PauuloG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PauuloG/subscriptions","organizations_url":"https://api.github.com/users/PauuloG/orgs","repos_url":"https://api.github.com/users/PauuloG/repos","events_url":"https://api.github.com/users/PauuloG/events{/privacy}","received_events_url":"https://api.github.com/users/PauuloG/received_events","type":"User","site_admin":false},"body":"Unit tests are ok but integration still fail on my end. \r\n\r\nWill investigate this tomorrow as I think it is environment related","created_at":"2018-05-01T17:03:27Z","updated_at":"2018-05-01T19:49:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7d848fab57d9cb277d0439c7a589b0ed6629583e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ZolaApp/zola-api/pulls/68/commits","review_comments_url":"https://api.github.com/repos/ZolaApp/zola-api/pulls/68/comments","review_comment_url":"https://api.github.com/repos/ZolaApp/zola-api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ZolaApp/zola-api/issues/68/comments","statuses_url":"https://api.github.com/repos/ZolaApp/zola-api/statuses/c52ca24c5a2dd5c2b66701defa7eedd65a08c9b8","head":{"label":"ZolaApp:improvement/tokenTests","ref":"improvement/tokenTests","sha":"c52ca24c5a2dd5c2b66701defa7eedd65a08c9b8","user":{"login":"ZolaApp","id":36263651,"avatar_url":"https://avatars2.githubusercontent.com/u/36263651?v=4","gravatar_id":"","url":"https://api.github.com/users/ZolaApp","html_url":"https://github.com/ZolaApp","followers_url":"https://api.github.com/users/ZolaApp/followers","following_url":"https://api.github.com/users/ZolaApp/following{/other_user}","gists_url":"https://api.github.com/users/ZolaApp/gists{/gist_id}","starred_url":"https://api.github.com/users/ZolaApp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZolaApp/subscriptions","organizations_url":"https://api.github.com/users/ZolaApp/orgs","repos_url":"https://api.github.com/users/ZolaApp/repos","events_url":"https://api.github.com/users/ZolaApp/events{/privacy}","received_events_url":"https://api.github.com/users/ZolaApp/received_events","type":"Organization","site_admin":false},"repo":{"id":128188501,"name":"zola-api","full_name":"ZolaApp/zola-api","owner":{"login":"ZolaApp","id":36263651,"avatar_url":"https://avatars2.githubusercontent.com/u/36263651?v=4","gravatar_id":"","url":"https://api.github.com/users/ZolaApp","html_url":"https://github.com/ZolaApp","followers_url":"https://api.github.com/users/ZolaApp/followers","following_url":"https://api.github.com/users/ZolaApp/following{/other_user}","gists_url":"https://api.github.com/users/ZolaApp/gists{/gist_id}","starred_url":"https://api.github.com/users/ZolaApp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZolaApp/subscriptions","organizations_url":"https://api.github.com/users/ZolaApp/orgs","repos_url":"https://api.github.com/users/ZolaApp/repos","events_url":"https://api.github.com/users/ZolaApp/events{/privacy}","received_events_url":"https://api.github.com/users/ZolaApp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ZolaApp/zola-api","description":"Zola’s API.","fork":false,"url":"https://api.github.com/repos/ZolaApp/zola-api","forks_url":"https://api.github.com/repos/ZolaApp/zola-api/forks","keys_url":"https://api.github.com/repos/ZolaApp/zola-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ZolaApp/zola-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ZolaApp/zola-api/teams","hooks_url":"https://api.github.com/repos/ZolaApp/zola-api/hooks","issue_events_url":"https://api.github.com/repos/ZolaApp/zola-api/issues/events{/number}","events_url":"https://api.github.com/repos/ZolaApp/zola-api/events","assignees_url":"https://api.github.com/repos/ZolaApp/zola-api/assignees{/user}","branches_url":"https://api.github.com/repos/ZolaApp/zola-api/branches{/branch}","tags_url":"https://api.github.com/repos/ZolaApp/zola-api/tags","blobs_url":"https://api.github.com/repos/ZolaApp/zola-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ZolaApp/zola-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ZolaApp/zola-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/ZolaApp/zola-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ZolaApp/zola-api/statuses/{sha}","languages_url":"https://api.github.com/repos/ZolaApp/zola-api/languages","stargazers_url":"https://api.github.com/repos/ZolaApp/zola-api/stargazers","contributors_url":"https://api.github.com/repos/ZolaApp/zola-api/contributors","subscribers_url":"https://api.github.com/repos/ZolaApp/zola-api/subscribers","subscription_url":"https://api.github.com/repos/ZolaApp/zola-api/subscription","commits_url":"https://api.github.com/repos/ZolaApp/zola-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/ZolaApp/zola-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/ZolaApp/zola-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/ZolaApp/zola-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/ZolaApp/zola-api/contents/{+path}","compare_url":"https://api.github.com/repos/ZolaApp/zola-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ZolaApp/zola-api/merges","archive_url":"https://api.github.com/repos/ZolaApp/zola-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ZolaApp/zola-api/downloads","issues_url":"https://api.github.com/repos/ZolaApp/zola-api/issues{/number}","pulls_url":"https://api.github.com/repos/ZolaApp/zola-api/pulls{/number}","milestones_url":"https://api.github.com/repos/ZolaApp/zola-api/milestones{/number}","notifications_url":"https://api.github.com/repos/ZolaApp/zola-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ZolaApp/zola-api/labels{/name}","releases_url":"https://api.github.com/repos/ZolaApp/zola-api/releases{/id}","deployments_url":"https://api.github.com/repos/ZolaApp/zola-api/deployments","created_at":"2018-04-05T10:01:01Z","updated_at":"2018-05-01T19:32:38Z","pushed_at":"2018-05-01T19:32:39Z","git_url":"git://github.com/ZolaApp/zola-api.git","ssh_url":"git@github.com:ZolaApp/zola-api.git","clone_url":"https://github.com/ZolaApp/zola-api.git","svn_url":"https://github.com/ZolaApp/zola-api","homepage":null,"size":543,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":8,"license":null,"forks":0,"open_issues":8,"watchers":0,"default_branch":"develop"}},"base":{"label":"ZolaApp:develop","ref":"develop","sha":"066b7a60a182ef70c9508f77bfc6506f986aaa07","user":{"login":"ZolaApp","id":36263651,"avatar_url":"https://avatars2.githubusercontent.com/u/36263651?v=4","gravatar_id":"","url":"https://api.github.com/users/ZolaApp","html_url":"https://github.com/ZolaApp","followers_url":"https://api.github.com/users/ZolaApp/followers","following_url":"https://api.github.com/users/ZolaApp/following{/other_user}","gists_url":"https://api.github.com/users/ZolaApp/gists{/gist_id}","starred_url":"https://api.github.com/users/ZolaApp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZolaApp/subscriptions","organizations_url":"https://api.github.com/users/ZolaApp/orgs","repos_url":"https://api.github.com/users/ZolaApp/repos","events_url":"https://api.github.com/users/ZolaApp/events{/privacy}","received_events_url":"https://api.github.com/users/ZolaApp/received_events","type":"Organization","site_admin":false},"repo":{"id":128188501,"name":"zola-api","full_name":"ZolaApp/zola-api","owner":{"login":"ZolaApp","id":36263651,"avatar_url":"https://avatars2.githubusercontent.com/u/36263651?v=4","gravatar_id":"","url":"https://api.github.com/users/ZolaApp","html_url":"https://github.com/ZolaApp","followers_url":"https://api.github.com/users/ZolaApp/followers","following_url":"https://api.github.com/users/ZolaApp/following{/other_user}","gists_url":"https://api.github.com/users/ZolaApp/gists{/gist_id}","starred_url":"https://api.github.com/users/ZolaApp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZolaApp/subscriptions","organizations_url":"https://api.github.com/users/ZolaApp/orgs","repos_url":"https://api.github.com/users/ZolaApp/repos","events_url":"https://api.github.com/users/ZolaApp/events{/privacy}","received_events_url":"https://api.github.com/users/ZolaApp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ZolaApp/zola-api","description":"Zola’s API.","fork":false,"url":"https://api.github.com/repos/ZolaApp/zola-api","forks_url":"https://api.github.com/repos/ZolaApp/zola-api/forks","keys_url":"https://api.github.com/repos/ZolaApp/zola-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ZolaApp/zola-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ZolaApp/zola-api/teams","hooks_url":"https://api.github.com/repos/ZolaApp/zola-api/hooks","issue_events_url":"https://api.github.com/repos/ZolaApp/zola-api/issues/events{/number}","events_url":"https://api.github.com/repos/ZolaApp/zola-api/events","assignees_url":"https://api.github.com/repos/ZolaApp/zola-api/assignees{/user}","branches_url":"https://api.github.com/repos/ZolaApp/zola-api/branches{/branch}","tags_url":"https://api.github.com/repos/ZolaApp/zola-api/tags","blobs_url":"https://api.github.com/repos/ZolaApp/zola-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ZolaApp/zola-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ZolaApp/zola-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/ZolaApp/zola-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ZolaApp/zola-api/statuses/{sha}","languages_url":"https://api.github.com/repos/ZolaApp/zola-api/languages","stargazers_url":"https://api.github.com/repos/ZolaApp/zola-api/stargazers","contributors_url":"https://api.github.com/repos/ZolaApp/zola-api/contributors","subscribers_url":"https://api.github.com/repos/ZolaApp/zola-api/subscribers","subscription_url":"https://api.github.com/repos/ZolaApp/zola-api/subscription","commits_url":"https://api.github.com/repos/ZolaApp/zola-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/ZolaApp/zola-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/ZolaApp/zola-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/ZolaApp/zola-api/issues/comments{/number}","contents_url":"https://api.github.com/repos/ZolaApp/zola-api/contents/{+path}","compare_url":"https://api.github.com/repos/ZolaApp/zola-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ZolaApp/zola-api/merges","archive_url":"https://api.github.com/repos/ZolaApp/zola-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ZolaApp/zola-api/downloads","issues_url":"https://api.github.com/repos/ZolaApp/zola-api/issues{/number}","pulls_url":"https://api.github.com/repos/ZolaApp/zola-api/pulls{/number}","milestones_url":"https://api.github.com/repos/ZolaApp/zola-api/milestones{/number}","notifications_url":"https://api.github.com/repos/ZolaApp/zola-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ZolaApp/zola-api/labels{/name}","releases_url":"https://api.github.com/repos/ZolaApp/zola-api/releases{/id}","deployments_url":"https://api.github.com/repos/ZolaApp/zola-api/deployments","created_at":"2018-04-05T10:01:01Z","updated_at":"2018-05-01T19:32:38Z","pushed_at":"2018-05-01T19:32:39Z","git_url":"git://github.com/ZolaApp/zola-api.git","ssh_url":"git@github.com:ZolaApp/zola-api.git","clone_url":"https://github.com/ZolaApp/zola-api.git","svn_url":"https://github.com/ZolaApp/zola-api","homepage":null,"size":543,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":8,"license":null,"forks":0,"open_issues":8,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ZolaApp/zola-api/pulls/68"},"html":{"href":"https://github.com/ZolaApp/zola-api/pull/68"},"issue":{"href":"https://api.github.com/repos/ZolaApp/zola-api/issues/68"},"comments":{"href":"https://api.github.com/repos/ZolaApp/zola-api/issues/68/comments"},"review_comments":{"href":"https://api.github.com/repos/ZolaApp/zola-api/pulls/68/comments"},"review_comment":{"href":"https://api.github.com/repos/ZolaApp/zola-api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ZolaApp/zola-api/pulls/68/commits"},"statuses":{"href":"https://api.github.com/repos/ZolaApp/zola-api/statuses/c52ca24c5a2dd5c2b66701defa7eedd65a08c9b8"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Tom-Bonnike"}}