{"action":"created","comment":{"url":"https://api.github.com/repos/keybase/go-updater/pulls/comments/60237776","id":60237776,"diff_hunk":"@@ -0,0 +1,77 @@\n+// Copyright 2015 Keybase, Inc. All rights reserved. Use of\n+// this source code is governed by the included BSD license.\n+\n+package keybase\n+\n+import (\n+\t\"os\"\n+\t\"path/filepath\"\n+\t\"testing\"\n+\n+\t\"github.com/keybase/go-updater\"\n+\t\"github.com/stretchr/testify/assert\"\n+)\n+\n+func testPromptWithCommand(t *testing.T, promptCommand string) (*updater.UpdatePromptResponse, error) {\n+\tcfg, _ := testConfig(t)\n+\tctx := newContext(&cfg, log)\n+\tassert.NotNil(t, ctx)\n+\n+\tupdate := updater.Update{\n+\t\tVersion:     \"1.2.3-400+sha\",\n+\t\tName:        \"Test\",\n+\t\tDescription: \"Bug fixes\",\n+\t}\n+\n+\toptions := cfg.updaterOptions()\n+\n+\tpromptOptions := updater.UpdatePromptOptions{AutoUpdate: false}\n+\n+\treturn ctx.updatePrompt(promptCommand, update, options, promptOptions)\n+}\n+\n+func TestPromptApply(t *testing.T) {\n+\tpromptCommand := filepath.Join(os.Getenv(\"GOPATH\"), \"src/github.com/keybase/go-updater/test/prompt-apply.sh\")\n+\tresp, err := testPromptWithCommand(t, promptCommand)\n+\tassert.NoError(t, err)\n+\tif assert.NotNil(t, resp) {\n+\t\tassert.True(t, resp.AutoUpdate)\n+\t\tassert.Equal(t, updater.UpdateActionApply, resp.Action)\n+\t}\n+}\n+\n+func TestPromptSnooze(t *testing.T) {\n+\tpromptCommand := filepath.Join(os.Getenv(\"GOPATH\"), \"src/github.com/keybase/go-updater/test/prompt-snooze.sh\")\n+\tresp, err := testPromptWithCommand(t, promptCommand)\n+\tassert.NoError(t, err)\n+\tif assert.NotNil(t, resp) {\n+\t\tassert.True(t, resp.AutoUpdate)\n+\t\tassert.Equal(t, updater.UpdateActionSnooze, resp.Action)\n+\t}\n+}\n+\n+func TestPromptCancel(t *testing.T) {\n+\tpromptCommand := filepath.Join(os.Getenv(\"GOPATH\"), \"src/github.com/keybase/go-updater/test/prompt-cancel.sh\")\n+\tresp, err := testPromptWithCommand(t, promptCommand)\n+\tassert.NoError(t, err)\n+\tif assert.NotNil(t, resp) {\n+\t\tassert.True(t, resp.AutoUpdate)\n+\t\tassert.Equal(t, updater.UpdateActionCancel, resp.Action)\n+\t}\n+}\n+\n+func TestPromptNoOutput(t *testing.T) {\n+\tresp, err := testPromptWithCommand(t, \"echo\")\n+\tassert.NoError(t, err)\n+\tif assert.NotNil(t, resp) {\n+\t\tassert.False(t, resp.AutoUpdate)\n+\t\tassert.Equal(t, updater.UpdateActionCancel, resp.Action)\n+\t}\n+}\n+\n+func TestPromptError(t *testing.T) {","path":"keybase/prompt_test.go","position":72,"original_position":72,"commit_id":"727692bb4337f4696f0a98eb39a31d0baee87485","original_commit_id":"727692bb4337f4696f0a98eb39a31d0baee87485","user":{"login":"chrisnojima","id":516435,"avatar_url":"https://avatars.githubusercontent.com/u/516435?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisnojima","html_url":"https://github.com/chrisnojima","followers_url":"https://api.github.com/users/chrisnojima/followers","following_url":"https://api.github.com/users/chrisnojima/following{/other_user}","gists_url":"https://api.github.com/users/chrisnojima/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisnojima/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisnojima/subscriptions","organizations_url":"https://api.github.com/users/chrisnojima/orgs","repos_url":"https://api.github.com/users/chrisnojima/repos","events_url":"https://api.github.com/users/chrisnojima/events{/privacy}","received_events_url":"https://api.github.com/users/chrisnojima/received_events","type":"User","site_admin":false},"body":"can we have a test to return invalid json","created_at":"2016-04-19T14:11:21Z","updated_at":"2016-04-19T14:11:21Z","html_url":"https://github.com/keybase/go-updater/pull/18#discussion_r60237776","pull_request_url":"https://api.github.com/repos/keybase/go-updater/pulls/18","_links":{"self":{"href":"https://api.github.com/repos/keybase/go-updater/pulls/comments/60237776"},"html":{"href":"https://github.com/keybase/go-updater/pull/18#discussion_r60237776"},"pull_request":{"href":"https://api.github.com/repos/keybase/go-updater/pulls/18"}}},"pull_request":{"url":"https://api.github.com/repos/keybase/go-updater/pulls/18","id":66934550,"html_url":"https://github.com/keybase/go-updater/pull/18","diff_url":"https://github.com/keybase/go-updater/pull/18.diff","patch_url":"https://github.com/keybase/go-updater/pull/18.patch","issue_url":"https://api.github.com/repos/keybase/go-updater/issues/18","number":18,"state":"open","locked":false,"title":"Prompt UI (command)","user":{"login":"gabriel","id":2669,"avatar_url":"https://avatars.githubusercontent.com/u/2669?v=3","gravatar_id":"","url":"https://api.github.com/users/gabriel","html_url":"https://github.com/gabriel","followers_url":"https://api.github.com/users/gabriel/followers","following_url":"https://api.github.com/users/gabriel/following{/other_user}","gists_url":"https://api.github.com/users/gabriel/gists{/gist_id}","starred_url":"https://api.github.com/users/gabriel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gabriel/subscriptions","organizations_url":"https://api.github.com/users/gabriel/orgs","repos_url":"https://api.github.com/users/gabriel/repos","events_url":"https://api.github.com/users/gabriel/events{/privacy}","received_events_url":"https://api.github.com/users/gabriel/received_events","type":"User","site_admin":false},"body":"Takes update and options and calls prompt UI. The tests use mocked out responses.","created_at":"2016-04-18T22:45:46Z","updated_at":"2016-04-19T14:11:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a4d000997acbeac619700f5781252c752e64617e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/keybase/go-updater/pulls/18/commits","review_comments_url":"https://api.github.com/repos/keybase/go-updater/pulls/18/comments","review_comment_url":"https://api.github.com/repos/keybase/go-updater/pulls/comments{/number}","comments_url":"https://api.github.com/repos/keybase/go-updater/issues/18/comments","statuses_url":"https://api.github.com/repos/keybase/go-updater/statuses/727692bb4337f4696f0a98eb39a31d0baee87485","head":{"label":"keybase:v2-prompt","ref":"v2-prompt","sha":"727692bb4337f4696f0a98eb39a31d0baee87485","user":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"repo":{"id":54599817,"name":"go-updater","full_name":"keybase/go-updater","owner":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/keybase/go-updater","description":"Update framework (golang)","fork":false,"url":"https://api.github.com/repos/keybase/go-updater","forks_url":"https://api.github.com/repos/keybase/go-updater/forks","keys_url":"https://api.github.com/repos/keybase/go-updater/keys{/key_id}","collaborators_url":"https://api.github.com/repos/keybase/go-updater/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/keybase/go-updater/teams","hooks_url":"https://api.github.com/repos/keybase/go-updater/hooks","issue_events_url":"https://api.github.com/repos/keybase/go-updater/issues/events{/number}","events_url":"https://api.github.com/repos/keybase/go-updater/events","assignees_url":"https://api.github.com/repos/keybase/go-updater/assignees{/user}","branches_url":"https://api.github.com/repos/keybase/go-updater/branches{/branch}","tags_url":"https://api.github.com/repos/keybase/go-updater/tags","blobs_url":"https://api.github.com/repos/keybase/go-updater/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/keybase/go-updater/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/keybase/go-updater/git/refs{/sha}","trees_url":"https://api.github.com/repos/keybase/go-updater/git/trees{/sha}","statuses_url":"https://api.github.com/repos/keybase/go-updater/statuses/{sha}","languages_url":"https://api.github.com/repos/keybase/go-updater/languages","stargazers_url":"https://api.github.com/repos/keybase/go-updater/stargazers","contributors_url":"https://api.github.com/repos/keybase/go-updater/contributors","subscribers_url":"https://api.github.com/repos/keybase/go-updater/subscribers","subscription_url":"https://api.github.com/repos/keybase/go-updater/subscription","commits_url":"https://api.github.com/repos/keybase/go-updater/commits{/sha}","git_commits_url":"https://api.github.com/repos/keybase/go-updater/git/commits{/sha}","comments_url":"https://api.github.com/repos/keybase/go-updater/comments{/number}","issue_comment_url":"https://api.github.com/repos/keybase/go-updater/issues/comments{/number}","contents_url":"https://api.github.com/repos/keybase/go-updater/contents/{+path}","compare_url":"https://api.github.com/repos/keybase/go-updater/compare/{base}...{head}","merges_url":"https://api.github.com/repos/keybase/go-updater/merges","archive_url":"https://api.github.com/repos/keybase/go-updater/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/keybase/go-updater/downloads","issues_url":"https://api.github.com/repos/keybase/go-updater/issues{/number}","pulls_url":"https://api.github.com/repos/keybase/go-updater/pulls{/number}","milestones_url":"https://api.github.com/repos/keybase/go-updater/milestones{/number}","notifications_url":"https://api.github.com/repos/keybase/go-updater/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/keybase/go-updater/labels{/name}","releases_url":"https://api.github.com/repos/keybase/go-updater/releases{/id}","deployments_url":"https://api.github.com/repos/keybase/go-updater/deployments","created_at":"2016-03-23T23:21:54Z","updated_at":"2016-04-11T05:52:37Z","pushed_at":"2016-04-19T00:35:23Z","git_url":"git://github.com/keybase/go-updater.git","ssh_url":"git@github.com:keybase/go-updater.git","clone_url":"https://github.com/keybase/go-updater.git","svn_url":"https://github.com/keybase/go-updater","homepage":null,"size":553,"stargazers_count":3,"watchers_count":3,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":3,"default_branch":"master"}},"base":{"label":"keybase:v2","ref":"v2","sha":"b46ad797fb67ca430dbca7c42af78a2a5ce6592b","user":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"repo":{"id":54599817,"name":"go-updater","full_name":"keybase/go-updater","owner":{"login":"keybase","id":5400834,"avatar_url":"https://avatars.githubusercontent.com/u/5400834?v=3","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/keybase/go-updater","description":"Update framework (golang)","fork":false,"url":"https://api.github.com/repos/keybase/go-updater","forks_url":"https://api.github.com/repos/keybase/go-updater/forks","keys_url":"https://api.github.com/repos/keybase/go-updater/keys{/key_id}","collaborators_url":"https://api.github.com/repos/keybase/go-updater/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/keybase/go-updater/teams","hooks_url":"https://api.github.com/repos/keybase/go-updater/hooks","issue_events_url":"https://api.github.com/repos/keybase/go-updater/issues/events{/number}","events_url":"https://api.github.com/repos/keybase/go-updater/events","assignees_url":"https://api.github.com/repos/keybase/go-updater/assignees{/user}","branches_url":"https://api.github.com/repos/keybase/go-updater/branches{/branch}","tags_url":"https://api.github.com/repos/keybase/go-updater/tags","blobs_url":"https://api.github.com/repos/keybase/go-updater/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/keybase/go-updater/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/keybase/go-updater/git/refs{/sha}","trees_url":"https://api.github.com/repos/keybase/go-updater/git/trees{/sha}","statuses_url":"https://api.github.com/repos/keybase/go-updater/statuses/{sha}","languages_url":"https://api.github.com/repos/keybase/go-updater/languages","stargazers_url":"https://api.github.com/repos/keybase/go-updater/stargazers","contributors_url":"https://api.github.com/repos/keybase/go-updater/contributors","subscribers_url":"https://api.github.com/repos/keybase/go-updater/subscribers","subscription_url":"https://api.github.com/repos/keybase/go-updater/subscription","commits_url":"https://api.github.com/repos/keybase/go-updater/commits{/sha}","git_commits_url":"https://api.github.com/repos/keybase/go-updater/git/commits{/sha}","comments_url":"https://api.github.com/repos/keybase/go-updater/comments{/number}","issue_comment_url":"https://api.github.com/repos/keybase/go-updater/issues/comments{/number}","contents_url":"https://api.github.com/repos/keybase/go-updater/contents/{+path}","compare_url":"https://api.github.com/repos/keybase/go-updater/compare/{base}...{head}","merges_url":"https://api.github.com/repos/keybase/go-updater/merges","archive_url":"https://api.github.com/repos/keybase/go-updater/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/keybase/go-updater/downloads","issues_url":"https://api.github.com/repos/keybase/go-updater/issues{/number}","pulls_url":"https://api.github.com/repos/keybase/go-updater/pulls{/number}","milestones_url":"https://api.github.com/repos/keybase/go-updater/milestones{/number}","notifications_url":"https://api.github.com/repos/keybase/go-updater/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/keybase/go-updater/labels{/name}","releases_url":"https://api.github.com/repos/keybase/go-updater/releases{/id}","deployments_url":"https://api.github.com/repos/keybase/go-updater/deployments","created_at":"2016-03-23T23:21:54Z","updated_at":"2016-04-11T05:52:37Z","pushed_at":"2016-04-19T00:35:23Z","git_url":"git://github.com/keybase/go-updater.git","ssh_url":"git@github.com:keybase/go-updater.git","clone_url":"https://github.com/keybase/go-updater.git","svn_url":"https://github.com/keybase/go-updater","homepage":null,"size":553,"stargazers_count":3,"watchers_count":3,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/keybase/go-updater/pulls/18"},"html":{"href":"https://github.com/keybase/go-updater/pull/18"},"issue":{"href":"https://api.github.com/repos/keybase/go-updater/issues/18"},"comments":{"href":"https://api.github.com/repos/keybase/go-updater/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/keybase/go-updater/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/keybase/go-updater/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/keybase/go-updater/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/keybase/go-updater/statuses/727692bb4337f4696f0a98eb39a31d0baee87485"}}}}