{"action":"created","comment":{"url":"https://api.github.com/repos/storj/storj/pulls/comments/214842136","pull_request_review_id":151940409,"id":214842136,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNDg0MjEzNg==","diff_hunk":"@@ -4,210 +4,52 @@\n package boltdb\n \n import (\n-\t\"bytes\"\n-\t\"fmt\"\n \t\"io/ioutil\"\n \t\"os\"\n+\t\"path/filepath\"\n \t\"testing\"\n \n-\t\"github.com/stretchr/testify/assert\"\n-\t\"go.uber.org/zap\"\n-\t\"storj.io/storj/storage\"\n+\t\"storj.io/storj/storage/testsuite\"\n )\n \n-type BoltClientTest struct {\n-\t*testing.T\n-\tc storage.KeyValueStore\n-}\n-\n-func NewBoltClientTest(t *testing.T) *BoltClientTest {\n-\tlogger, _ := zap.NewDevelopment()\n-\tdbName := tempfile()\n-\n-\tc, err := NewClient(logger, dbName, \"test_bucket\")\n-\tif err != nil {\n-\t\tt.Error(\"Failed to create test db\")\n-\t\tpanic(err)\n-\t}\n-\n-\treturn &BoltClientTest{\n-\t\tT: t,\n-\t\tc: c,\n-\t}\n-}\n-\n-func (bt *BoltClientTest) Close() {\n-\tbt.c.Close()\n-\tswitch client := bt.c.(type) {\n-\tcase *Client:\n-\t\tos.Remove(client.Path)\n-\t}\n-}\n-\n-func (bt *BoltClientTest) HandleErr(err error, msg string) {\n-\tbt.Error(msg)\n-\tif err != nil {\n-\t\tpanic(err)\n-\t}\n-\tpanic(msg)\n-}\n-\n-func tempfile() string {\n-\tf, err := ioutil.TempFile(\"\", \"TempBolt-\")\n-\tif err != nil {\n-\t\tpanic(err)\n-\t}\n-\tf.Close()\n-\terr = os.Remove(f.Name())\n+func TestSuite(t *testing.T) {\n+\ttempdir, err := ioutil.TempDir(\"\", \"bolt\")\n \tif err != nil {\n-\t\tpanic(err)\n-\t}\n-\treturn f.Name()\n-}\n-\n-func TestPut(t *testing.T) {\n-\tbt := NewBoltClientTest(t)\n-\tdefer bt.Close()\n-\n-\tif err := bt.c.Put([]byte(\"test/path/1\"), []byte(\"pointer1\")); err != nil {\n-\t\tbt.HandleErr(err, \"Failed to save pointer1 to pointers bucket\")\n+\t\tt.Fatal(err)\n \t}\n-}\n+\tdefer os.RemoveAll(tempdir)\n \n-func TestGet(t *testing.T) {\n-\tbt := NewBoltClientTest(t)\n-\tdefer bt.Close()\n-\n-\tif err := bt.c.Put([]byte(\"test/path/1\"), []byte(\"pointer1\")); err != nil {\n-\t\tbt.HandleErr(err, \"Failed to save pointer1 to pointers bucket\")\n-\t}\n-\n-\tretrvValue, err := bt.c.Get([]byte(\"test/path/1\"))\n+\tdbname := filepath.Join(tempdir, \"bolt.db\")\n+\tstore, err := New(dbname, \"bucket\")\n \tif err != nil {\n-\t\tbt.HandleErr(err, \"Failed to get\")\n-\t}\n-\tif retrvValue.IsZero() {\n-\t\tbt.HandleErr(nil, \"Failed to get saved test pointer\")\n-\t}\n-\tif !bytes.Equal(retrvValue, []byte(\"pointer1\")) {\n-\t\tbt.HandleErr(nil, \"Retrieved pointer was not same as put pointer\")\n-\t}\n-\n-\t// tests Get non-existent path\n-\tgetRes, err := bt.c.Get([]byte(\"fake/path\"))\n-\n-\t// here we are expecting an error for an empty file\n-\tassert.Nil(t, getRes)\n-\tassert.True(t, storage.ErrKeyNotFound.Has(err))\n-}\n-\n-func TestDelete(t *testing.T) {\n-\tbt := NewBoltClientTest(t)\n-\tdefer bt.Close()\n-\n-\tif err := bt.c.Put([]byte(\"test/path/1\"), []byte(\"pointer1\")); err != nil {\n-\t\tbt.HandleErr(err, \"Failed to save pointer1 to pointers bucket\")\n+\t\tt.Fatalf(\"failed to create db: %v\", err)\n \t}\n+\tdefer func() {","path":"storage/boltdb/client_test.go","position":117,"original_position":117,"commit_id":"9e20637f6265ed6a13208f4ef82627e787693147","original_commit_id":"7e02f8222677f6f6e82687a23f21bc427e17ad9c","user":{"login":"kaloyan-raev","id":468091,"node_id":"MDQ6VXNlcjQ2ODA5MQ==","avatar_url":"https://avatars2.githubusercontent.com/u/468091?v=4","gravatar_id":"","url":"https://api.github.com/users/kaloyan-raev","html_url":"https://github.com/kaloyan-raev","followers_url":"https://api.github.com/users/kaloyan-raev/followers","following_url":"https://api.github.com/users/kaloyan-raev/following{/other_user}","gists_url":"https://api.github.com/users/kaloyan-raev/gists{/gist_id}","starred_url":"https://api.github.com/users/kaloyan-raev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaloyan-raev/subscriptions","organizations_url":"https://api.github.com/users/kaloyan-raev/orgs","repos_url":"https://api.github.com/users/kaloyan-raev/repos","events_url":"https://api.github.com/users/kaloyan-raev/events{/privacy}","received_events_url":"https://api.github.com/users/kaloyan-raev/received_events","type":"User","site_admin":false},"body":"You can use `defer utils.LogClose(store)` here.","created_at":"2018-09-04T09:14:03Z","updated_at":"2018-09-04T09:54:48Z","html_url":"https://github.com/storj/storj/pull/303#discussion_r214842136","pull_request_url":"https://api.github.com/repos/storj/storj/pulls/303","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/storj/storj/pulls/comments/214842136"},"html":{"href":"https://github.com/storj/storj/pull/303#discussion_r214842136"},"pull_request":{"href":"https://api.github.com/repos/storj/storj/pulls/303"}}},"pull_request":{"url":"https://api.github.com/repos/storj/storj/pulls/303","id":212179089,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEyMTc5MDg5","html_url":"https://github.com/storj/storj/pull/303","diff_url":"https://github.com/storj/storj/pull/303.diff","patch_url":"https://github.com/storj/storj/pull/303.patch","issue_url":"https://api.github.com/repos/storj/storj/issues/303","number":303,"state":"open","locked":false,"title":"Implement ListV2 with storage rework","user":{"login":"egonelbre","id":192964,"node_id":"MDQ6VXNlcjE5Mjk2NA==","avatar_url":"https://avatars1.githubusercontent.com/u/192964?v=4","gravatar_id":"","url":"https://api.github.com/users/egonelbre","html_url":"https://github.com/egonelbre","followers_url":"https://api.github.com/users/egonelbre/followers","following_url":"https://api.github.com/users/egonelbre/following{/other_user}","gists_url":"https://api.github.com/users/egonelbre/gists{/gist_id}","starred_url":"https://api.github.com/users/egonelbre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/egonelbre/subscriptions","organizations_url":"https://api.github.com/users/egonelbre/orgs","repos_url":"https://api.github.com/users/egonelbre/repos","events_url":"https://api.github.com/users/egonelbre/events{/privacy}","received_events_url":"https://api.github.com/users/egonelbre/received_events","type":"User","site_admin":false},"body":"1. Added `KeyValueStore.Iterate` and `KeyValueStore.IterateAll` for implementing the different List, ListV2 etc. implementations. This allows for more efficient use of memory depending on the situation.\r\n1. Added `KeyValueStore.IterateReverse` and `KeyValueStore.IterateReverseAll`.\r\n2. Implemented an inmemory `teststore` for running tests. This should allow to replace `MockKeyValueStore` in most places.\r\n3. Rewrote all the tests\r\n4. Pulled out logger from bolt implementation so it can be used for all other storage implementations.\r\n5. Fixed multiple things in bolt and redis implementations.\r\n\r\n_Sorry for the large PR_\r\n\r\n<!-- Reviewable:start -->\r\n---\r\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/storj/storj/303)\r\n<!-- Reviewable:end -->\r\n","created_at":"2018-08-30T19:00:43Z","updated_at":"2018-09-04T09:54:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3dd5627b36ebe2622ccd88dd01f687705c1a4485","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":982933521,"node_id":"MDU6TGFiZWw5ODI5MzM1MjE=","url":"https://api.github.com/repos/storj/storj/labels/cla-signed","name":"cla-signed","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/storj/storj/pulls/303/commits","review_comments_url":"https://api.github.com/repos/storj/storj/pulls/303/comments","review_comment_url":"https://api.github.com/repos/storj/storj/pulls/comments{/number}","comments_url":"https://api.github.com/repos/storj/storj/issues/303/comments","statuses_url":"https://api.github.com/repos/storj/storj/statuses/9e20637f6265ed6a13208f4ef82627e787693147","head":{"label":"storj:storage","ref":"storage","sha":"9e20637f6265ed6a13208f4ef82627e787693147","user":{"login":"storj","id":6308081,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYzMDgwODE=","avatar_url":"https://avatars3.githubusercontent.com/u/6308081?v=4","gravatar_id":"","url":"https://api.github.com/users/storj","html_url":"https://github.com/storj","followers_url":"https://api.github.com/users/storj/followers","following_url":"https://api.github.com/users/storj/following{/other_user}","gists_url":"https://api.github.com/users/storj/gists{/gist_id}","starred_url":"https://api.github.com/users/storj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/storj/subscriptions","organizations_url":"https://api.github.com/users/storj/orgs","repos_url":"https://api.github.com/users/storj/repos","events_url":"https://api.github.com/users/storj/events{/privacy}","received_events_url":"https://api.github.com/users/storj/received_events","type":"Organization","site_admin":false},"repo":{"id":128089774,"node_id":"MDEwOlJlcG9zaXRvcnkxMjgwODk3NzQ=","name":"storj","full_name":"storj/storj","owner":{"login":"storj","id":6308081,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYzMDgwODE=","avatar_url":"https://avatars3.githubusercontent.com/u/6308081?v=4","gravatar_id":"","url":"https://api.github.com/users/storj","html_url":"https://github.com/storj","followers_url":"https://api.github.com/users/storj/followers","following_url":"https://api.github.com/users/storj/following{/other_user}","gists_url":"https://api.github.com/users/storj/gists{/gist_id}","starred_url":"https://api.github.com/users/storj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/storj/subscriptions","organizations_url":"https://api.github.com/users/storj/orgs","repos_url":"https://api.github.com/users/storj/repos","events_url":"https://api.github.com/users/storj/events{/privacy}","received_events_url":"https://api.github.com/users/storj/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/storj/storj","description":"Ongoing Storj v3 development. Decentralized cloud object storage that is affordable, easy to use, private, and secure.","fork":false,"url":"https://api.github.com/repos/storj/storj","forks_url":"https://api.github.com/repos/storj/storj/forks","keys_url":"https://api.github.com/repos/storj/storj/keys{/key_id}","collaborators_url":"https://api.github.com/repos/storj/storj/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/storj/storj/teams","hooks_url":"https://api.github.com/repos/storj/storj/hooks","issue_events_url":"https://api.github.com/repos/storj/storj/issues/events{/number}","events_url":"https://api.github.com/repos/storj/storj/events","assignees_url":"https://api.github.com/repos/storj/storj/assignees{/user}","branches_url":"https://api.github.com/repos/storj/storj/branches{/branch}","tags_url":"https://api.github.com/repos/storj/storj/tags","blobs_url":"https://api.github.com/repos/storj/storj/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/storj/storj/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/storj/storj/git/refs{/sha}","trees_url":"https://api.github.com/repos/storj/storj/git/trees{/sha}","statuses_url":"https://api.github.com/repos/storj/storj/statuses/{sha}","languages_url":"https://api.github.com/repos/storj/storj/languages","stargazers_url":"https://api.github.com/repos/storj/storj/stargazers","contributors_url":"https://api.github.com/repos/storj/storj/contributors","subscribers_url":"https://api.github.com/repos/storj/storj/subscribers","subscription_url":"https://api.github.com/repos/storj/storj/subscription","commits_url":"https://api.github.com/repos/storj/storj/commits{/sha}","git_commits_url":"https://api.github.com/repos/storj/storj/git/commits{/sha}","comments_url":"https://api.github.com/repos/storj/storj/comments{/number}","issue_comment_url":"https://api.github.com/repos/storj/storj/issues/comments{/number}","contents_url":"https://api.github.com/repos/storj/storj/contents/{+path}","compare_url":"https://api.github.com/repos/storj/storj/compare/{base}...{head}","merges_url":"https://api.github.com/repos/storj/storj/merges","archive_url":"https://api.github.com/repos/storj/storj/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/storj/storj/downloads","issues_url":"https://api.github.com/repos/storj/storj/issues{/number}","pulls_url":"https://api.github.com/repos/storj/storj/pulls{/number}","milestones_url":"https://api.github.com/repos/storj/storj/milestones{/number}","notifications_url":"https://api.github.com/repos/storj/storj/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/storj/storj/labels{/name}","releases_url":"https://api.github.com/repos/storj/storj/releases{/id}","deployments_url":"https://api.github.com/repos/storj/storj/deployments","created_at":"2018-04-04T16:27:18Z","updated_at":"2018-09-04T09:20:13Z","pushed_at":"2018-09-04T07:23:37Z","git_url":"git://github.com/storj/storj.git","ssh_url":"git@github.com:storj/storj.git","clone_url":"https://github.com/storj/storj.git","svn_url":"https://github.com/storj/storj","homepage":"https://storj.io","size":10945,"stargazers_count":163,"watchers_count":163,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":41,"mirror_url":null,"archived":false,"open_issues_count":15,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":41,"open_issues":15,"watchers":163,"default_branch":"master"}},"base":{"label":"storj:master","ref":"master","sha":"743ec652047fac10360f5b0572a974f502ed9991","user":{"login":"storj","id":6308081,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYzMDgwODE=","avatar_url":"https://avatars3.githubusercontent.com/u/6308081?v=4","gravatar_id":"","url":"https://api.github.com/users/storj","html_url":"https://github.com/storj","followers_url":"https://api.github.com/users/storj/followers","following_url":"https://api.github.com/users/storj/following{/other_user}","gists_url":"https://api.github.com/users/storj/gists{/gist_id}","starred_url":"https://api.github.com/users/storj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/storj/subscriptions","organizations_url":"https://api.github.com/users/storj/orgs","repos_url":"https://api.github.com/users/storj/repos","events_url":"https://api.github.com/users/storj/events{/privacy}","received_events_url":"https://api.github.com/users/storj/received_events","type":"Organization","site_admin":false},"repo":{"id":128089774,"node_id":"MDEwOlJlcG9zaXRvcnkxMjgwODk3NzQ=","name":"storj","full_name":"storj/storj","owner":{"login":"storj","id":6308081,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYzMDgwODE=","avatar_url":"https://avatars3.githubusercontent.com/u/6308081?v=4","gravatar_id":"","url":"https://api.github.com/users/storj","html_url":"https://github.com/storj","followers_url":"https://api.github.com/users/storj/followers","following_url":"https://api.github.com/users/storj/following{/other_user}","gists_url":"https://api.github.com/users/storj/gists{/gist_id}","starred_url":"https://api.github.com/users/storj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/storj/subscriptions","organizations_url":"https://api.github.com/users/storj/orgs","repos_url":"https://api.github.com/users/storj/repos","events_url":"https://api.github.com/users/storj/events{/privacy}","received_events_url":"https://api.github.com/users/storj/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/storj/storj","description":"Ongoing Storj v3 development. Decentralized cloud object storage that is affordable, easy to use, private, and secure.","fork":false,"url":"https://api.github.com/repos/storj/storj","forks_url":"https://api.github.com/repos/storj/storj/forks","keys_url":"https://api.github.com/repos/storj/storj/keys{/key_id}","collaborators_url":"https://api.github.com/repos/storj/storj/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/storj/storj/teams","hooks_url":"https://api.github.com/repos/storj/storj/hooks","issue_events_url":"https://api.github.com/repos/storj/storj/issues/events{/number}","events_url":"https://api.github.com/repos/storj/storj/events","assignees_url":"https://api.github.com/repos/storj/storj/assignees{/user}","branches_url":"https://api.github.com/repos/storj/storj/branches{/branch}","tags_url":"https://api.github.com/repos/storj/storj/tags","blobs_url":"https://api.github.com/repos/storj/storj/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/storj/storj/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/storj/storj/git/refs{/sha}","trees_url":"https://api.github.com/repos/storj/storj/git/trees{/sha}","statuses_url":"https://api.github.com/repos/storj/storj/statuses/{sha}","languages_url":"https://api.github.com/repos/storj/storj/languages","stargazers_url":"https://api.github.com/repos/storj/storj/stargazers","contributors_url":"https://api.github.com/repos/storj/storj/contributors","subscribers_url":"https://api.github.com/repos/storj/storj/subscribers","subscription_url":"https://api.github.com/repos/storj/storj/subscription","commits_url":"https://api.github.com/repos/storj/storj/commits{/sha}","git_commits_url":"https://api.github.com/repos/storj/storj/git/commits{/sha}","comments_url":"https://api.github.com/repos/storj/storj/comments{/number}","issue_comment_url":"https://api.github.com/repos/storj/storj/issues/comments{/number}","contents_url":"https://api.github.com/repos/storj/storj/contents/{+path}","compare_url":"https://api.github.com/repos/storj/storj/compare/{base}...{head}","merges_url":"https://api.github.com/repos/storj/storj/merges","archive_url":"https://api.github.com/repos/storj/storj/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/storj/storj/downloads","issues_url":"https://api.github.com/repos/storj/storj/issues{/number}","pulls_url":"https://api.github.com/repos/storj/storj/pulls{/number}","milestones_url":"https://api.github.com/repos/storj/storj/milestones{/number}","notifications_url":"https://api.github.com/repos/storj/storj/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/storj/storj/labels{/name}","releases_url":"https://api.github.com/repos/storj/storj/releases{/id}","deployments_url":"https://api.github.com/repos/storj/storj/deployments","created_at":"2018-04-04T16:27:18Z","updated_at":"2018-09-04T09:20:13Z","pushed_at":"2018-09-04T07:23:37Z","git_url":"git://github.com/storj/storj.git","ssh_url":"git@github.com:storj/storj.git","clone_url":"https://github.com/storj/storj.git","svn_url":"https://github.com/storj/storj","homepage":"https://storj.io","size":10945,"stargazers_count":163,"watchers_count":163,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":41,"mirror_url":null,"archived":false,"open_issues_count":15,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":41,"open_issues":15,"watchers":163,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/storj/storj/pulls/303"},"html":{"href":"https://github.com/storj/storj/pull/303"},"issue":{"href":"https://api.github.com/repos/storj/storj/issues/303"},"comments":{"href":"https://api.github.com/repos/storj/storj/issues/303/comments"},"review_comments":{"href":"https://api.github.com/repos/storj/storj/pulls/303/comments"},"review_comment":{"href":"https://api.github.com/repos/storj/storj/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/storj/storj/pulls/303/commits"},"statuses":{"href":"https://api.github.com/repos/storj/storj/statuses/9e20637f6265ed6a13208f4ef82627e787693147"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"kaloyan-raev"}}