{"action":"created","comment":{"url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments/25230349","id":25230349,"diff_hunk":"@@ -0,0 +1,166 @@\n+package readonly\n+\n+import (\n+\t\"bytes\"\n+\t\"crypto/rand\"\n+\t//context \"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context\"\n+\t\"io/ioutil\"\n+\t\"os\"\n+\t\"testing\"\n+\n+\tfstest \"github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs/fstestutil\"\n+\n+\tcore \"github.com/jbenet/go-ipfs/core\"\n+\timporter \"github.com/jbenet/go-ipfs/importer\"\n+\tchunk \"github.com/jbenet/go-ipfs/importer/chunk\"\n+\tdag \"github.com/jbenet/go-ipfs/merkledag\"\n+\tuio \"github.com/jbenet/go-ipfs/unixfs/io\"\n+\tu \"github.com/jbenet/go-ipfs/util\"\n+\tci \"github.com/jbenet/go-ipfs/util/testutil/ci\"\n+)\n+\n+func maybeSkipFuseTests(t *testing.T) {\n+\tif ci.NoFuse() {\n+\t\tt.Skip(\"Skipping FUSE tests\")\n+\t}\n+}\n+\n+func randBytes(size int) []byte {\n+\tb := make([]byte, size)\n+\trand.Read(b)\n+\treturn b\n+}\n+\n+func randObj(t *testing.T, nd *core.IpfsNode, size int64) (*dag.Node, []byte) {\n+\tbuf := make([]byte, size)\n+\tu.NewTimeSeededRand().Read(buf)\n+\tread := bytes.NewReader(buf)\n+\tobj, err := importer.BuildTrickleDagFromReader(read, nd.DAG, nil, chunk.DefaultSplitter)\n+\tif err != nil {\n+\t\tt.Fatal(err)\n+\t}\n+\n+\treturn obj, buf\n+}\n+\n+func setupIpfsTest(t *testing.T, node *core.IpfsNode) (*core.IpfsNode, *fstest.Mount) {\n+\tmaybeSkipFuseTests(t)\n+\n+\tvar err error\n+\tif node == nil {\n+\t\tnode, err = core.NewMockNode()\n+\t\tif err != nil {\n+\t\t\tt.Fatal(err)\n+\t\t}\n+\t}\n+\n+\tfs := NewFileSystem(node)\n+\tmnt, err := fstest.MountedT(t, fs)\n+\tif err != nil {\n+\t\tt.Fatal(err)\n+\t}\n+\n+\treturn node, mnt\n+}\n+\n+// Test writing an object and reading it back through fuse\n+func TestIpfsBasicRead(t *testing.T) {\n+\tif testing.Short() {\n+\t\tt.SkipNow()\n+\t}\n+\tnd, mnt := setupIpfsTest(t, nil)\n+\tdefer mnt.Close()\n+\n+\tfi, data := randObj(t, nd, 10000)\n+\tk, err := fi.Key()\n+\tif err != nil {\n+\t\tt.Fatal(err)\n+\t}\n+\n+\tfname := mnt.Dir + \"/\" + k.String()\n+\trbuf, err := ioutil.ReadFile(fname)\n+\tif err != nil {\n+\t\tt.Fatal(err)\n+\t}\n+\n+\tif !bytes.Equal(rbuf, data) {\n+\t\tt.Fatal(\"Incorrect Read!\")\n+\t}\n+}\n+\n+// Test writing a file and reading it back\n+func TestIpfsBasicDirRead(t *testing.T) {\n+\tif testing.Short() {\n+\t\tt.SkipNow()\n+\t}\n+\tnd, mnt := setupIpfsTest(t, nil)\n+\tdefer mnt.Close()\n+\n+\t// Make a 'file'\n+\tfi, data := randObj(t, nd, 10000)\n+\tk, err := fi.Key()\n+\tif err != nil {\n+\t\tt.Fatal(err)\n+\t}\n+\n+\t// Make a directory and put that file in it\n+\tdb := uio.NewDirectory(nd.DAG)\n+\terr = db.AddChild(\"actual\", k)\n+\tif err != nil {\n+\t\tt.Fatal(err)\n+\t}\n+\n+\td1nd := db.GetNode()\n+\td1ndk, err := nd.DAG.Add(d1nd)\n+\tif err != nil {\n+\t\tt.Fatal(err)\n+\t}\n+\n+\tdirname := mnt.Dir + \"/\" + d1ndk.String()\n+\tfname := dirname + \"/actual\"","path":"fuse/readonly/ipfs_test.go","position":120,"original_position":120,"commit_id":"dbf071fa674f91237d6040c2810334445f2e8dce","original_commit_id":"dbf071fa674f91237d6040c2810334445f2e8dce","user":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"body":"should probably use `path.Join` for multiplatform goodness","created_at":"2015-02-24T05:49:16Z","updated_at":"2015-02-24T05:49:16Z","html_url":"https://github.com/jbenet/go-ipfs/pull/809#discussion_r25230349","pull_request_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/809","_links":{"self":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments/25230349"},"html":{"href":"https://github.com/jbenet/go-ipfs/pull/809#discussion_r25230349"},"pull_request":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/809"}}},"pull_request":{"url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/809","id":29870621,"html_url":"https://github.com/jbenet/go-ipfs/pull/809","diff_url":"https://github.com/jbenet/go-ipfs/pull/809.diff","patch_url":"https://github.com/jbenet/go-ipfs/pull/809.patch","issue_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/809","number":809,"state":"open","locked":false,"title":"Add a few tests to fuse/readonly","user":{"login":"whyrusleeping","id":1243164,"avatar_url":"https://avatars.githubusercontent.com/u/1243164?v=3","gravatar_id":"","url":"https://api.github.com/users/whyrusleeping","html_url":"https://github.com/whyrusleeping","followers_url":"https://api.github.com/users/whyrusleeping/followers","following_url":"https://api.github.com/users/whyrusleeping/following{/other_user}","gists_url":"https://api.github.com/users/whyrusleeping/gists{/gist_id}","starred_url":"https://api.github.com/users/whyrusleeping/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whyrusleeping/subscriptions","organizations_url":"https://api.github.com/users/whyrusleeping/orgs","repos_url":"https://api.github.com/users/whyrusleeping/repos","events_url":"https://api.github.com/users/whyrusleeping/events{/privacy}","received_events_url":"https://api.github.com/users/whyrusleeping/received_events","type":"User","site_admin":false},"body":"This achieves around 75% code coverage, which is pretty good considering some of the code is platform specific, and it counts not hitting the error returns.","created_at":"2015-02-24T04:41:43Z","updated_at":"2015-02-24T05:49:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5fd82036a40d6ae85f69d39bec2f32d6dd712b97","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/809/commits","review_comments_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/809/comments","review_comment_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/809/comments","statuses_url":"https://api.github.com/repos/jbenet/go-ipfs/statuses/dbf071fa674f91237d6040c2810334445f2e8dce","head":{"label":"jbenet:feat/ipfs-fuse-tests","ref":"feat/ipfs-fuse-tests","sha":"dbf071fa674f91237d6040c2810334445f2e8dce","user":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"repo":{"id":21233191,"name":"go-ipfs","full_name":"jbenet/go-ipfs","owner":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jbenet/go-ipfs","description":"ipfs implementation in go","fork":false,"url":"https://api.github.com/repos/jbenet/go-ipfs","forks_url":"https://api.github.com/repos/jbenet/go-ipfs/forks","keys_url":"https://api.github.com/repos/jbenet/go-ipfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jbenet/go-ipfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jbenet/go-ipfs/teams","hooks_url":"https://api.github.com/repos/jbenet/go-ipfs/hooks","issue_events_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/events{/number}","events_url":"https://api.github.com/repos/jbenet/go-ipfs/events","assignees_url":"https://api.github.com/repos/jbenet/go-ipfs/assignees{/user}","branches_url":"https://api.github.com/repos/jbenet/go-ipfs/branches{/branch}","tags_url":"https://api.github.com/repos/jbenet/go-ipfs/tags","blobs_url":"https://api.github.com/repos/jbenet/go-ipfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jbenet/go-ipfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jbenet/go-ipfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/jbenet/go-ipfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jbenet/go-ipfs/statuses/{sha}","languages_url":"https://api.github.com/repos/jbenet/go-ipfs/languages","stargazers_url":"https://api.github.com/repos/jbenet/go-ipfs/stargazers","contributors_url":"https://api.github.com/repos/jbenet/go-ipfs/contributors","subscribers_url":"https://api.github.com/repos/jbenet/go-ipfs/subscribers","subscription_url":"https://api.github.com/repos/jbenet/go-ipfs/subscription","commits_url":"https://api.github.com/repos/jbenet/go-ipfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/jbenet/go-ipfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/jbenet/go-ipfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/comments{/number}","contents_url":"https://api.github.com/repos/jbenet/go-ipfs/contents/{+path}","compare_url":"https://api.github.com/repos/jbenet/go-ipfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jbenet/go-ipfs/merges","archive_url":"https://api.github.com/repos/jbenet/go-ipfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jbenet/go-ipfs/downloads","issues_url":"https://api.github.com/repos/jbenet/go-ipfs/issues{/number}","pulls_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls{/number}","milestones_url":"https://api.github.com/repos/jbenet/go-ipfs/milestones{/number}","notifications_url":"https://api.github.com/repos/jbenet/go-ipfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jbenet/go-ipfs/labels{/name}","releases_url":"https://api.github.com/repos/jbenet/go-ipfs/releases{/id}","created_at":"2014-06-26T08:14:34Z","updated_at":"2015-02-24T04:51:13Z","pushed_at":"2015-02-24T05:33:35Z","git_url":"git://github.com/jbenet/go-ipfs.git","ssh_url":"git@github.com:jbenet/go-ipfs.git","clone_url":"https://github.com/jbenet/go-ipfs.git","svn_url":"https://github.com/jbenet/go-ipfs","homepage":"https://github.com/jbenet/ipfs","size":28621,"stargazers_count":309,"watchers_count":309,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":40,"mirror_url":null,"open_issues_count":165,"forks":40,"open_issues":165,"watchers":309,"default_branch":"master"}},"base":{"label":"jbenet:master","ref":"master","sha":"5ea2afc4b2035744c14b5ae3df3a53932c0f292b","user":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"repo":{"id":21233191,"name":"go-ipfs","full_name":"jbenet/go-ipfs","owner":{"login":"jbenet","id":138401,"avatar_url":"https://avatars.githubusercontent.com/u/138401?v=3","gravatar_id":"","url":"https://api.github.com/users/jbenet","html_url":"https://github.com/jbenet","followers_url":"https://api.github.com/users/jbenet/followers","following_url":"https://api.github.com/users/jbenet/following{/other_user}","gists_url":"https://api.github.com/users/jbenet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbenet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbenet/subscriptions","organizations_url":"https://api.github.com/users/jbenet/orgs","repos_url":"https://api.github.com/users/jbenet/repos","events_url":"https://api.github.com/users/jbenet/events{/privacy}","received_events_url":"https://api.github.com/users/jbenet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jbenet/go-ipfs","description":"ipfs implementation in go","fork":false,"url":"https://api.github.com/repos/jbenet/go-ipfs","forks_url":"https://api.github.com/repos/jbenet/go-ipfs/forks","keys_url":"https://api.github.com/repos/jbenet/go-ipfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jbenet/go-ipfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jbenet/go-ipfs/teams","hooks_url":"https://api.github.com/repos/jbenet/go-ipfs/hooks","issue_events_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/events{/number}","events_url":"https://api.github.com/repos/jbenet/go-ipfs/events","assignees_url":"https://api.github.com/repos/jbenet/go-ipfs/assignees{/user}","branches_url":"https://api.github.com/repos/jbenet/go-ipfs/branches{/branch}","tags_url":"https://api.github.com/repos/jbenet/go-ipfs/tags","blobs_url":"https://api.github.com/repos/jbenet/go-ipfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jbenet/go-ipfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jbenet/go-ipfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/jbenet/go-ipfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jbenet/go-ipfs/statuses/{sha}","languages_url":"https://api.github.com/repos/jbenet/go-ipfs/languages","stargazers_url":"https://api.github.com/repos/jbenet/go-ipfs/stargazers","contributors_url":"https://api.github.com/repos/jbenet/go-ipfs/contributors","subscribers_url":"https://api.github.com/repos/jbenet/go-ipfs/subscribers","subscription_url":"https://api.github.com/repos/jbenet/go-ipfs/subscription","commits_url":"https://api.github.com/repos/jbenet/go-ipfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/jbenet/go-ipfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/jbenet/go-ipfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/jbenet/go-ipfs/issues/comments{/number}","contents_url":"https://api.github.com/repos/jbenet/go-ipfs/contents/{+path}","compare_url":"https://api.github.com/repos/jbenet/go-ipfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jbenet/go-ipfs/merges","archive_url":"https://api.github.com/repos/jbenet/go-ipfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jbenet/go-ipfs/downloads","issues_url":"https://api.github.com/repos/jbenet/go-ipfs/issues{/number}","pulls_url":"https://api.github.com/repos/jbenet/go-ipfs/pulls{/number}","milestones_url":"https://api.github.com/repos/jbenet/go-ipfs/milestones{/number}","notifications_url":"https://api.github.com/repos/jbenet/go-ipfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jbenet/go-ipfs/labels{/name}","releases_url":"https://api.github.com/repos/jbenet/go-ipfs/releases{/id}","created_at":"2014-06-26T08:14:34Z","updated_at":"2015-02-24T04:51:13Z","pushed_at":"2015-02-24T05:33:35Z","git_url":"git://github.com/jbenet/go-ipfs.git","ssh_url":"git@github.com:jbenet/go-ipfs.git","clone_url":"https://github.com/jbenet/go-ipfs.git","svn_url":"https://github.com/jbenet/go-ipfs","homepage":"https://github.com/jbenet/ipfs","size":28621,"stargazers_count":309,"watchers_count":309,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":40,"mirror_url":null,"open_issues_count":165,"forks":40,"open_issues":165,"watchers":309,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/809"},"html":{"href":"https://github.com/jbenet/go-ipfs/pull/809"},"issue":{"href":"https://api.github.com/repos/jbenet/go-ipfs/issues/809"},"comments":{"href":"https://api.github.com/repos/jbenet/go-ipfs/issues/809/comments"},"review_comments":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/809/comments"},"review_comment":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jbenet/go-ipfs/pulls/809/commits"},"statuses":{"href":"https://api.github.com/repos/jbenet/go-ipfs/statuses/dbf071fa674f91237d6040c2810334445f2e8dce"}}}}