{"action":"created","comment":{"url":"https://api.github.com/repos/docker/machine/pulls/comments/41963064","id":41963064,"diff_hunk":"@@ -1,10 +1,207 @@\n package virtualbox\n \n import (\n+\t\"errors\"\n \t\"net\"\n+\t\"strings\"\n \t\"testing\"\n+\n+\t\"github.com/codegangsta/cli\"\n+\t\"github.com/docker/machine/libmachine/state\"\n+\t\"github.com/stretchr/testify/assert\"\n )\n \n+func TestDriverName(t *testing.T) {\n+\tdriverName := newDriver(\"default\").DriverName()\n+\n+\tassert.Equal(t, \"virtualbox\", driverName)\n+}\n+\n+func TestDefaultFlags(t *testing.T) {\n+\tdriver, err := create([]string{\"test-name\"})\n+\n+\tassert.NoError(t, err)\n+\tassert.Equal(t, driver.CPU, 1)\n+\tassert.Equal(t, driver.Memory, 1024)\n+\tassert.Equal(t, driver.DiskSize, 20000)\n+\tassert.Equal(t, driver.Boot2DockerURL, \"\")\n+\tassert.Equal(t, driver.Boot2DockerImportVM, \"\")\n+\tassert.Equal(t, driver.HostOnlyCIDR, \"192.168.99.1/24\")\n+\tassert.Equal(t, driver.HostOnlyNicType, \"82540EM\")\n+\tassert.Equal(t, driver.HostOnlyPromiscMode, \"deny\")\n+\tassert.Equal(t, driver.NoShare, false)\n+}\n+\n+func TestCustomFlags(t *testing.T) {\n+\tdriver, err := create([]string{\n+\t\t\"--virtualbox-cpu-count\", \"8\",\n+\t\t\"--virtualbox-memory\", \"4096\",\n+\t\t\"--virtualbox-disk-size\", \"100000\",\n+\t\t\"--virtualbox-boot2docker-url\", \"test-boot2docker-url\",\n+\t\t\"--virtualbox-import-boot2docker-vm\", \"test-boot2docker-vm\",\n+\t\t\"--virtualbox-hostonly-cidr\", \"192.168.99.1/8\",\n+\t\t\"--virtualbox-hostonly-nictype\", \"test-nic-type\",\n+\t\t\"--virtualbox-hostonly-nicpromisc\", \"accept\",\n+\t\t\"--virtualbox-no-share\",\n+\t\t\"test-name\"})\n+\n+\tassert.NoError(t, err)\n+\tassert.Equal(t, driver.CPU, 8)\n+\tassert.Equal(t, driver.Memory, 4096)\n+\tassert.Equal(t, driver.DiskSize, 100000)\n+\tassert.Equal(t, driver.Boot2DockerURL, \"test-boot2docker-url\")\n+\tassert.Equal(t, driver.Boot2DockerImportVM, \"test-boot2docker-vm\")\n+\tassert.Equal(t, driver.HostOnlyCIDR, \"192.168.99.1/8\")\n+\tassert.Equal(t, driver.HostOnlyNicType, \"test-nic-type\")\n+\tassert.Equal(t, driver.HostOnlyPromiscMode, \"accept\")\n+\tassert.Equal(t, driver.NoShare, true)\n+}\n+\n+func TestSSHHostname(t *testing.T) {\n+\thostname, err := newDriver(\"default\").GetSSHHostname()\n+\n+\tassert.Equal(t, \"127.0.0.1\", hostname)\n+\tassert.NoError(t, err)\n+}\n+\n+func TestDefaultSSHUsername(t *testing.T) {\n+\tusername := newDriver(\"default\").GetSSHUsername()\n+\n+\tassert.Equal(t, \"docker\", username)\n+}\n+\n+type VBoxManagerMock struct {\n+\texpectedArgs string\n+\toutput       string\n+\tstdErr       string\n+\terr          error\n+}\n+\n+func (v *VBoxManagerMock) queryVirtualBox(args ...string) (string, string, error) {\n+\tif strings.Join(args, \" \") == v.expectedArgs {\n+\t\treturn v.output, v.stdErr, v.err\n+\t}\n+\treturn \"\", \"\", errors.New(\"Invalid args\")\n+}\n+\n+func TestStateRunning(t *testing.T) {\n+\tdriver := newDriver(\"default\")\n+\tdriver.VBoxManager = &VBoxManagerMock{\n+\t\texpectedArgs: \"showvminfo default --machinereadable\",\n+\t\toutput:       `VMState=\"running\"`,\n+\t}\n+\n+\tmachineState, err := driver.GetState()\n+\n+\tassert.Equal(t, state.Running, machineState)\n+\tassert.NoError(t, err)\n+}\n+\n+func TestStatePaused(t *testing.T) {\n+\tdriver := newDriver(\"default\")\n+\tdriver.VBoxManager = &VBoxManagerMock{\n+\t\texpectedArgs: \"showvminfo default --machinereadable\",\n+\t\toutput:       `VMState=\"paused\"`,\n+\t}\n+\n+\tmachineState, err := driver.GetState()\n+\n+\tassert.Equal(t, state.Paused, machineState)\n+\tassert.NoError(t, err)\n+}\n+\n+func TestStateSaved(t *testing.T) {\n+\tdriver := newDriver(\"default\")\n+\tdriver.VBoxManager = &VBoxManagerMock{\n+\t\texpectedArgs: \"showvminfo default --machinereadable\",\n+\t\toutput:       `VMState=\"saved\"`,\n+\t}\n+\n+\tmachineState, err := driver.GetState()\n+\n+\tassert.Equal(t, state.Saved, machineState)\n+\tassert.NoError(t, err)\n+}\n+\n+func TestStateStopped(t *testing.T) {\n+\tdriver := newDriver(\"default\")\n+\tdriver.VBoxManager = &VBoxManagerMock{\n+\t\texpectedArgs: \"showvminfo default --machinereadable\",\n+\t\toutput:       `VMState=\"poweroff\"`,\n+\t}\n+\n+\tmachineState, err := driver.GetState()\n+\n+\tassert.Equal(t, state.Stopped, machineState)\n+\tassert.NoError(t, err)\n+}\n+\n+func TestStateAborted(t *testing.T) {\n+\tdriver := newDriver(\"default\")\n+\tdriver.VBoxManager = &VBoxManagerMock{\n+\t\texpectedArgs: \"showvminfo default --machinereadable\",\n+\t\toutput:       `VMState=\"aborted\"`,\n+\t}\n+\n+\tmachineState, err := driver.GetState()\n+\n+\tassert.Equal(t, state.Stopped, machineState)\n+\tassert.NoError(t, err)\n+}\n+\n+func TestStateUnknown(t *testing.T) {\n+\tdriver := newDriver(\"default\")\n+\tdriver.VBoxManager = &VBoxManagerMock{\n+\t\texpectedArgs: \"showvminfo default --machinereadable\",\n+\t\toutput:       `VMState=\"whatever\"`,\n+\t}\n+\n+\tmachineState, err := driver.GetState()\n+\n+\tassert.Equal(t, state.None, machineState)\n+\tassert.NoError(t, err) // Really?","path":"drivers/virtualbox/virtualbox_test.go","position":162,"original_position":162,"commit_id":"4554ccc78a34baaa5abca6703c8638402465883e","original_commit_id":"4554ccc78a34baaa5abca6703c8638402465883e","user":{"login":"dgageot","id":153495,"avatar_url":"https://avatars.githubusercontent.com/u/153495?v=3","gravatar_id":"","url":"https://api.github.com/users/dgageot","html_url":"https://github.com/dgageot","followers_url":"https://api.github.com/users/dgageot/followers","following_url":"https://api.github.com/users/dgageot/following{/other_user}","gists_url":"https://api.github.com/users/dgageot/gists{/gist_id}","starred_url":"https://api.github.com/users/dgageot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgageot/subscriptions","organizations_url":"https://api.github.com/users/dgageot/orgs","repos_url":"https://api.github.com/users/dgageot/repos","events_url":"https://api.github.com/users/dgageot/events{/privacy}","received_events_url":"https://api.github.com/users/dgageot/received_events","type":"User","site_admin":false},"body":"yes ;-) I'll cover the code as is for now until I get more confidence in changing the actual code","created_at":"2015-10-14T07:38:28Z","updated_at":"2015-10-14T07:38:28Z","html_url":"https://github.com/docker/machine/pull/1976#discussion_r41963064","pull_request_url":"https://api.github.com/repos/docker/machine/pulls/1976","_links":{"self":{"href":"https://api.github.com/repos/docker/machine/pulls/comments/41963064"},"html":{"href":"https://github.com/docker/machine/pull/1976#discussion_r41963064"},"pull_request":{"href":"https://api.github.com/repos/docker/machine/pulls/1976"}}},"pull_request":{"url":"https://api.github.com/repos/docker/machine/pulls/1976","id":47443585,"html_url":"https://github.com/docker/machine/pull/1976","diff_url":"https://github.com/docker/machine/pull/1976.diff","patch_url":"https://github.com/docker/machine/pull/1976.patch","issue_url":"https://api.github.com/repos/docker/machine/issues/1976","number":1976,"state":"open","locked":false,"title":"[WIP] Add tests to virtualbox driver","user":{"login":"dgageot","id":153495,"avatar_url":"https://avatars.githubusercontent.com/u/153495?v=3","gravatar_id":"","url":"https://api.github.com/users/dgageot","html_url":"https://github.com/dgageot","followers_url":"https://api.github.com/users/dgageot/followers","following_url":"https://api.github.com/users/dgageot/following{/other_user}","gists_url":"https://api.github.com/users/dgageot/gists{/gist_id}","starred_url":"https://api.github.com/users/dgageot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgageot/subscriptions","organizations_url":"https://api.github.com/users/dgageot/orgs","repos_url":"https://api.github.com/users/dgageot/repos","events_url":"https://api.github.com/users/dgageot/events{/privacy}","received_events_url":"https://api.github.com/users/dgageot/received_events","type":"User","site_admin":false},"body":"This is an ongoing PR aiming at increasing test coverage for the virtualbox driver","created_at":"2015-10-12T17:15:07Z","updated_at":"2015-10-14T07:38:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"39b5b9a1655839c946d2c80d1a930d0a6d004b75","assignee":{"login":"dgageot","id":153495,"avatar_url":"https://avatars.githubusercontent.com/u/153495?v=3","gravatar_id":"","url":"https://api.github.com/users/dgageot","html_url":"https://github.com/dgageot","followers_url":"https://api.github.com/users/dgageot/followers","following_url":"https://api.github.com/users/dgageot/following{/other_user}","gists_url":"https://api.github.com/users/dgageot/gists{/gist_id}","starred_url":"https://api.github.com/users/dgageot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgageot/subscriptions","organizations_url":"https://api.github.com/users/dgageot/orgs","repos_url":"https://api.github.com/users/dgageot/repos","events_url":"https://api.github.com/users/dgageot/events{/privacy}","received_events_url":"https://api.github.com/users/dgageot/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/docker/machine/milestones/5","html_url":"https://github.com/docker/machine/milestones/0.5.0","labels_url":"https://api.github.com/repos/docker/machine/milestones/5/labels","id":1219188,"number":5,"title":"0.5.0","description":"","creator":{"login":"nathanleclaire","id":1476820,"avatar_url":"https://avatars.githubusercontent.com/u/1476820?v=3","gravatar_id":"","url":"https://api.github.com/users/nathanleclaire","html_url":"https://github.com/nathanleclaire","followers_url":"https://api.github.com/users/nathanleclaire/followers","following_url":"https://api.github.com/users/nathanleclaire/following{/other_user}","gists_url":"https://api.github.com/users/nathanleclaire/gists{/gist_id}","starred_url":"https://api.github.com/users/nathanleclaire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathanleclaire/subscriptions","organizations_url":"https://api.github.com/users/nathanleclaire/orgs","repos_url":"https://api.github.com/users/nathanleclaire/repos","events_url":"https://api.github.com/users/nathanleclaire/events{/privacy}","received_events_url":"https://api.github.com/users/nathanleclaire/received_events","type":"User","site_admin":false},"open_issues":31,"closed_issues":33,"state":"open","created_at":"2015-07-21T21:58:41Z","updated_at":"2015-10-14T07:20:05Z","due_on":"2015-10-29T04:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/docker/machine/pulls/1976/commits","review_comments_url":"https://api.github.com/repos/docker/machine/pulls/1976/comments","review_comment_url":"https://api.github.com/repos/docker/machine/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/machine/issues/1976/comments","statuses_url":"https://api.github.com/repos/docker/machine/statuses/4554ccc78a34baaa5abca6703c8638402465883e","head":{"label":"dgageot:add-tests-virtualbox-driver","ref":"add-tests-virtualbox-driver","sha":"4554ccc78a34baaa5abca6703c8638402465883e","user":{"login":"dgageot","id":153495,"avatar_url":"https://avatars.githubusercontent.com/u/153495?v=3","gravatar_id":"","url":"https://api.github.com/users/dgageot","html_url":"https://github.com/dgageot","followers_url":"https://api.github.com/users/dgageot/followers","following_url":"https://api.github.com/users/dgageot/following{/other_user}","gists_url":"https://api.github.com/users/dgageot/gists{/gist_id}","starred_url":"https://api.github.com/users/dgageot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgageot/subscriptions","organizations_url":"https://api.github.com/users/dgageot/orgs","repos_url":"https://api.github.com/users/dgageot/repos","events_url":"https://api.github.com/users/dgageot/events{/privacy}","received_events_url":"https://api.github.com/users/dgageot/received_events","type":"User","site_admin":false},"repo":{"id":35428053,"name":"machine","full_name":"dgageot/machine","owner":{"login":"dgageot","id":153495,"avatar_url":"https://avatars.githubusercontent.com/u/153495?v=3","gravatar_id":"","url":"https://api.github.com/users/dgageot","html_url":"https://github.com/dgageot","followers_url":"https://api.github.com/users/dgageot/followers","following_url":"https://api.github.com/users/dgageot/following{/other_user}","gists_url":"https://api.github.com/users/dgageot/gists{/gist_id}","starred_url":"https://api.github.com/users/dgageot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgageot/subscriptions","organizations_url":"https://api.github.com/users/dgageot/orgs","repos_url":"https://api.github.com/users/dgageot/repos","events_url":"https://api.github.com/users/dgageot/events{/privacy}","received_events_url":"https://api.github.com/users/dgageot/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dgageot/machine","description":"Machine management for a container-centric world","fork":true,"url":"https://api.github.com/repos/dgageot/machine","forks_url":"https://api.github.com/repos/dgageot/machine/forks","keys_url":"https://api.github.com/repos/dgageot/machine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dgageot/machine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dgageot/machine/teams","hooks_url":"https://api.github.com/repos/dgageot/machine/hooks","issue_events_url":"https://api.github.com/repos/dgageot/machine/issues/events{/number}","events_url":"https://api.github.com/repos/dgageot/machine/events","assignees_url":"https://api.github.com/repos/dgageot/machine/assignees{/user}","branches_url":"https://api.github.com/repos/dgageot/machine/branches{/branch}","tags_url":"https://api.github.com/repos/dgageot/machine/tags","blobs_url":"https://api.github.com/repos/dgageot/machine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dgageot/machine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dgageot/machine/git/refs{/sha}","trees_url":"https://api.github.com/repos/dgageot/machine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dgageot/machine/statuses/{sha}","languages_url":"https://api.github.com/repos/dgageot/machine/languages","stargazers_url":"https://api.github.com/repos/dgageot/machine/stargazers","contributors_url":"https://api.github.com/repos/dgageot/machine/contributors","subscribers_url":"https://api.github.com/repos/dgageot/machine/subscribers","subscription_url":"https://api.github.com/repos/dgageot/machine/subscription","commits_url":"https://api.github.com/repos/dgageot/machine/commits{/sha}","git_commits_url":"https://api.github.com/repos/dgageot/machine/git/commits{/sha}","comments_url":"https://api.github.com/repos/dgageot/machine/comments{/number}","issue_comment_url":"https://api.github.com/repos/dgageot/machine/issues/comments{/number}","contents_url":"https://api.github.com/repos/dgageot/machine/contents/{+path}","compare_url":"https://api.github.com/repos/dgageot/machine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dgageot/machine/merges","archive_url":"https://api.github.com/repos/dgageot/machine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dgageot/machine/downloads","issues_url":"https://api.github.com/repos/dgageot/machine/issues{/number}","pulls_url":"https://api.github.com/repos/dgageot/machine/pulls{/number}","milestones_url":"https://api.github.com/repos/dgageot/machine/milestones{/number}","notifications_url":"https://api.github.com/repos/dgageot/machine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dgageot/machine/labels{/name}","releases_url":"https://api.github.com/repos/dgageot/machine/releases{/id}","created_at":"2015-05-11T14:11:59Z","updated_at":"2015-05-11T14:12:00Z","pushed_at":"2015-10-14T07:25:56Z","git_url":"git://github.com/dgageot/machine.git","ssh_url":"git@github.com:dgageot/machine.git","clone_url":"https://github.com/dgageot/machine.git","svn_url":"https://github.com/dgageot/machine","homepage":"https://docs.docker.com/machine/","size":13440,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"ebd45f5d9bdfdb3890ce3a53f5b3e1ff54a6c834","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":27494663,"name":"machine","full_name":"docker/machine","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/machine","description":"Machine management for a container-centric world","fork":false,"url":"https://api.github.com/repos/docker/machine","forks_url":"https://api.github.com/repos/docker/machine/forks","keys_url":"https://api.github.com/repos/docker/machine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/machine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/machine/teams","hooks_url":"https://api.github.com/repos/docker/machine/hooks","issue_events_url":"https://api.github.com/repos/docker/machine/issues/events{/number}","events_url":"https://api.github.com/repos/docker/machine/events","assignees_url":"https://api.github.com/repos/docker/machine/assignees{/user}","branches_url":"https://api.github.com/repos/docker/machine/branches{/branch}","tags_url":"https://api.github.com/repos/docker/machine/tags","blobs_url":"https://api.github.com/repos/docker/machine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/machine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/machine/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/machine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/machine/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/machine/languages","stargazers_url":"https://api.github.com/repos/docker/machine/stargazers","contributors_url":"https://api.github.com/repos/docker/machine/contributors","subscribers_url":"https://api.github.com/repos/docker/machine/subscribers","subscription_url":"https://api.github.com/repos/docker/machine/subscription","commits_url":"https://api.github.com/repos/docker/machine/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/machine/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/machine/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/machine/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/machine/contents/{+path}","compare_url":"https://api.github.com/repos/docker/machine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/machine/merges","archive_url":"https://api.github.com/repos/docker/machine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/machine/downloads","issues_url":"https://api.github.com/repos/docker/machine/issues{/number}","pulls_url":"https://api.github.com/repos/docker/machine/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/machine/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/machine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/machine/labels{/name}","releases_url":"https://api.github.com/repos/docker/machine/releases{/id}","created_at":"2014-12-03T15:52:06Z","updated_at":"2015-10-14T07:14:57Z","pushed_at":"2015-10-14T07:25:57Z","git_url":"git://github.com/docker/machine.git","ssh_url":"git@github.com:docker/machine.git","clone_url":"https://github.com/docker/machine.git","svn_url":"https://github.com/docker/machine","homepage":"https://docs.docker.com/machine/","size":36370,"stargazers_count":2551,"watchers_count":2551,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":545,"mirror_url":null,"open_issues_count":421,"forks":545,"open_issues":421,"watchers":2551,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/machine/pulls/1976"},"html":{"href":"https://github.com/docker/machine/pull/1976"},"issue":{"href":"https://api.github.com/repos/docker/machine/issues/1976"},"comments":{"href":"https://api.github.com/repos/docker/machine/issues/1976/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/machine/pulls/1976/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/machine/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/machine/pulls/1976/commits"},"statuses":{"href":"https://api.github.com/repos/docker/machine/statuses/4554ccc78a34baaa5abca6703c8638402465883e"}}}}