{"action":"created","comment":{"url":"https://api.github.com/repos/juttle/juttle/pulls/comments/57030712","id":57030712,"diff_hunk":"@@ -0,0 +1,139 @@\n+'use strict';\n+\n+var juttle_test_utils = require('./specs/juttle-test-utils');\n+var check_juttle = juttle_test_utils.check_juttle;\n+var path = require('path');\n+var expect = require('chai').expect;\n+var _ = require('underscore');\n+var adapters = require('../../lib/runtime/adapters');\n+\n+\n+function configure(name, conf) {\n+    conf = _.clone(conf);\n+    conf.path = path.resolve(__dirname, '../runtime/test-adapter-conf');\n+    \n+    var configurePayload = {};\n+    configurePayload[name] = conf;\n+    \n+    adapters.configure(configurePayload);\n+}\n+\n+describe('init and read from config', function () {\n+    \n+    it('load single object', function() {\n+        var inputConf = {\n+            host: 'testHostA'\n+        };\n+        var name = inputConf.host;\n+        configure(name, inputConf);\n+        \n+        return check_juttle({\n+            program: `read ${name}`\n+        })\n+        .then(function(result) {\n+            expect(result.sinks.table).to.have.length(1);\n+            \n+            var outputConf = result.sinks.table;\n+            expect(outputConf[0]).to.deep.equal(inputConf);\n+        });\n+    });\n+    \n+    it('load array', function() {\n+        var inputConf = [\n+            {\n+                id: 'first',\n+                host: 'testHost1'\n+            },\n+            {\n+                id: 'second',\n+                host: 'testHost2'\n+            }\n+        ];\n+        var name = inputConf[0].host;\n+        configure(name, inputConf);\n+        \n+        return check_juttle({\n+            program: `read ${name}`\n+        })\n+        .then(function(result) {\n+            expect(result.sinks.table).to.have.length(inputConf.length);\n+            \n+            var outputConf = result.sinks.table;\n+            expect(outputConf).to.deep.equal(inputConf);\n+        });\n+    });\n+    \n+    it('load conf under instances key', function() {\n+        var inputConf = { \n+            instances: [\n+                {\n+                    id: 'first',\n+                    host: 'testHost3'\n+                },\n+                {\n+                    id: 'second',\n+                    host: 'testHost4'\n+                }\n+            ] \n+        };\n+        var name = inputConf.instances[0].host;\n+        configure(name, inputConf);\n+        \n+        return check_juttle({\n+            program: `read ${name}`\n+        })\n+        .then(function(result) {\n+            expect(result.sinks.table).to.have.length(inputConf.instances.length);\n+            \n+            var outputConf = result.sinks.table;\n+            expect(outputConf).to.deep.equal(inputConf.instances);\n+        });\n+    });\n+    \n+    it('err missing id', function() {\n+        var inputConf = [\n+            {\n+                host: 'testHost5'\n+            },\n+            {\n+                id: 'second',\n+                host: 'testHost6'\n+            }\n+        ];\n+        var name = inputConf[0].host;\n+        configure(name, inputConf);\n+        \n+        return check_juttle({\n+            program: `read ${name}`\n+        })\n+        .then(function(result) {\n+            throw new Error('unexpected success');\n+        })\n+        .catch(function(err) {\n+            expect(err.message).equal(`One or more configuation instances for adapter ${name} is missing an id.`);\n+        });\n+    });\n+    \n+    it('err instances not array', function() {\n+        var inputConf = { \n+            instances: {\n+                id: 'first',\n+                host: 'testHost7'\n+            },\n+            host: 'hostPlaceholder1'\n+        };\n+        \n+        var name = inputConf.host;\n+        configure(name, inputConf);\n+        \n+        return check_juttle({\n+            program: `read ${name}`\n+        })\n+        .then(function(result) {\n+            throw new Error('unexpected success');\n+        })\n+        .catch(function(err) {\n+            expect(err.message).equal(`instances key in configuation for adapter ${name} must be an array.`);\n+        });\n+    });\n+});","path":"test/runtime/adapter-config.spec.js","position":139,"original_position":139,"commit_id":"1748ffe07dc4ca48155b40571e29b30809e57b3c","original_commit_id":"1748ffe07dc4ca48155b40571e29b30809e57b3c","user":{"login":"demmer","id":3308504,"avatar_url":"https://avatars.githubusercontent.com/u/3308504?v=3","gravatar_id":"","url":"https://api.github.com/users/demmer","html_url":"https://github.com/demmer","followers_url":"https://api.github.com/users/demmer/followers","following_url":"https://api.github.com/users/demmer/following{/other_user}","gists_url":"https://api.github.com/users/demmer/gists{/gist_id}","starred_url":"https://api.github.com/users/demmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/demmer/subscriptions","organizations_url":"https://api.github.com/users/demmer/orgs","repos_url":"https://api.github.com/users/demmer/repos","events_url":"https://api.github.com/users/demmer/events{/privacy}","received_events_url":"https://api.github.com/users/demmer/received_events","type":"User","site_admin":false},"body":"I think it'd also be good to have some tests to verify what happens when `path` points to a nonexistent directory or an otherwise invalid path, coupled with the change above.\r\n","created_at":"2016-03-22T17:28:37Z","updated_at":"2016-03-22T17:28:37Z","html_url":"https://github.com/juttle/juttle/pull/641#discussion_r57030712","pull_request_url":"https://api.github.com/repos/juttle/juttle/pulls/641","_links":{"self":{"href":"https://api.github.com/repos/juttle/juttle/pulls/comments/57030712"},"html":{"href":"https://github.com/juttle/juttle/pull/641#discussion_r57030712"},"pull_request":{"href":"https://api.github.com/repos/juttle/juttle/pulls/641"}}},"pull_request":{"url":"https://api.github.com/repos/juttle/juttle/pulls/641","id":63642516,"html_url":"https://github.com/juttle/juttle/pull/641","diff_url":"https://github.com/juttle/juttle/pull/641.diff","patch_url":"https://github.com/juttle/juttle/pull/641.patch","issue_url":"https://api.github.com/repos/juttle/juttle/issues/641","number":641,"state":"open","locked":false,"title":"Standard adapter config","user":{"login":"VladVega","id":661577,"avatar_url":"https://avatars.githubusercontent.com/u/661577?v=3","gravatar_id":"","url":"https://api.github.com/users/VladVega","html_url":"https://github.com/VladVega","followers_url":"https://api.github.com/users/VladVega/followers","following_url":"https://api.github.com/users/VladVega/following{/other_user}","gists_url":"https://api.github.com/users/VladVega/gists{/gist_id}","starred_url":"https://api.github.com/users/VladVega/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VladVega/subscriptions","organizations_url":"https://api.github.com/users/VladVega/orgs","repos_url":"https://api.github.com/users/VladVega/repos","events_url":"https://api.github.com/users/VladVega/events{/privacy}","received_events_url":"https://api.github.com/users/VladVega/received_events","type":"User","site_admin":false},"body":"Implemented config standardization talked about here: https://github.com/juttle/juttle/pull/555\r\n\r\nThis will not be merged before this next release. We'll wait until the next one because we'll need to bump the adapter API anyway for the next one anyway.","created_at":"2016-03-21T22:25:33Z","updated_at":"2016-03-22T17:28:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15c558d2a0a6a9b4b6137cb6a8fd38964ae25688","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/juttle/juttle/pulls/641/commits","review_comments_url":"https://api.github.com/repos/juttle/juttle/pulls/641/comments","review_comment_url":"https://api.github.com/repos/juttle/juttle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/juttle/juttle/issues/641/comments","statuses_url":"https://api.github.com/repos/juttle/juttle/statuses/1748ffe07dc4ca48155b40571e29b30809e57b3c","head":{"label":"juttle:standard-adapter-config","ref":"standard-adapter-config","sha":"1748ffe07dc4ca48155b40571e29b30809e57b3c","user":{"login":"juttle","id":8988633,"avatar_url":"https://avatars.githubusercontent.com/u/8988633?v=3","gravatar_id":"","url":"https://api.github.com/users/juttle","html_url":"https://github.com/juttle","followers_url":"https://api.github.com/users/juttle/followers","following_url":"https://api.github.com/users/juttle/following{/other_user}","gists_url":"https://api.github.com/users/juttle/gists{/gist_id}","starred_url":"https://api.github.com/users/juttle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juttle/subscriptions","organizations_url":"https://api.github.com/users/juttle/orgs","repos_url":"https://api.github.com/users/juttle/repos","events_url":"https://api.github.com/users/juttle/events{/privacy}","received_events_url":"https://api.github.com/users/juttle/received_events","type":"Organization","site_admin":false},"repo":{"id":48260003,"name":"juttle","full_name":"juttle/juttle","owner":{"login":"juttle","id":8988633,"avatar_url":"https://avatars.githubusercontent.com/u/8988633?v=3","gravatar_id":"","url":"https://api.github.com/users/juttle","html_url":"https://github.com/juttle","followers_url":"https://api.github.com/users/juttle/followers","following_url":"https://api.github.com/users/juttle/following{/other_user}","gists_url":"https://api.github.com/users/juttle/gists{/gist_id}","starred_url":"https://api.github.com/users/juttle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juttle/subscriptions","organizations_url":"https://api.github.com/users/juttle/orgs","repos_url":"https://api.github.com/users/juttle/repos","events_url":"https://api.github.com/users/juttle/events{/privacy}","received_events_url":"https://api.github.com/users/juttle/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/juttle/juttle","description":"Juttle dataflow programming language","fork":false,"url":"https://api.github.com/repos/juttle/juttle","forks_url":"https://api.github.com/repos/juttle/juttle/forks","keys_url":"https://api.github.com/repos/juttle/juttle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juttle/juttle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juttle/juttle/teams","hooks_url":"https://api.github.com/repos/juttle/juttle/hooks","issue_events_url":"https://api.github.com/repos/juttle/juttle/issues/events{/number}","events_url":"https://api.github.com/repos/juttle/juttle/events","assignees_url":"https://api.github.com/repos/juttle/juttle/assignees{/user}","branches_url":"https://api.github.com/repos/juttle/juttle/branches{/branch}","tags_url":"https://api.github.com/repos/juttle/juttle/tags","blobs_url":"https://api.github.com/repos/juttle/juttle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juttle/juttle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juttle/juttle/git/refs{/sha}","trees_url":"https://api.github.com/repos/juttle/juttle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juttle/juttle/statuses/{sha}","languages_url":"https://api.github.com/repos/juttle/juttle/languages","stargazers_url":"https://api.github.com/repos/juttle/juttle/stargazers","contributors_url":"https://api.github.com/repos/juttle/juttle/contributors","subscribers_url":"https://api.github.com/repos/juttle/juttle/subscribers","subscription_url":"https://api.github.com/repos/juttle/juttle/subscription","commits_url":"https://api.github.com/repos/juttle/juttle/commits{/sha}","git_commits_url":"https://api.github.com/repos/juttle/juttle/git/commits{/sha}","comments_url":"https://api.github.com/repos/juttle/juttle/comments{/number}","issue_comment_url":"https://api.github.com/repos/juttle/juttle/issues/comments{/number}","contents_url":"https://api.github.com/repos/juttle/juttle/contents/{+path}","compare_url":"https://api.github.com/repos/juttle/juttle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juttle/juttle/merges","archive_url":"https://api.github.com/repos/juttle/juttle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juttle/juttle/downloads","issues_url":"https://api.github.com/repos/juttle/juttle/issues{/number}","pulls_url":"https://api.github.com/repos/juttle/juttle/pulls{/number}","milestones_url":"https://api.github.com/repos/juttle/juttle/milestones{/number}","notifications_url":"https://api.github.com/repos/juttle/juttle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juttle/juttle/labels{/name}","releases_url":"https://api.github.com/repos/juttle/juttle/releases{/id}","deployments_url":"https://api.github.com/repos/juttle/juttle/deployments","created_at":"2015-12-18T22:50:40Z","updated_at":"2016-03-22T16:16:33Z","pushed_at":"2016-03-22T16:54:40Z","git_url":"git://github.com/juttle/juttle.git","ssh_url":"git@github.com:juttle/juttle.git","clone_url":"https://github.com/juttle/juttle.git","svn_url":"https://github.com/juttle/juttle","homepage":"http://juttle.github.io/","size":5725,"stargazers_count":144,"watchers_count":144,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":9,"mirror_url":null,"open_issues_count":127,"forks":9,"open_issues":127,"watchers":144,"default_branch":"master"}},"base":{"label":"juttle:master","ref":"master","sha":"9db407a1d07da943c541fc1691ae6618e4229d91","user":{"login":"juttle","id":8988633,"avatar_url":"https://avatars.githubusercontent.com/u/8988633?v=3","gravatar_id":"","url":"https://api.github.com/users/juttle","html_url":"https://github.com/juttle","followers_url":"https://api.github.com/users/juttle/followers","following_url":"https://api.github.com/users/juttle/following{/other_user}","gists_url":"https://api.github.com/users/juttle/gists{/gist_id}","starred_url":"https://api.github.com/users/juttle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juttle/subscriptions","organizations_url":"https://api.github.com/users/juttle/orgs","repos_url":"https://api.github.com/users/juttle/repos","events_url":"https://api.github.com/users/juttle/events{/privacy}","received_events_url":"https://api.github.com/users/juttle/received_events","type":"Organization","site_admin":false},"repo":{"id":48260003,"name":"juttle","full_name":"juttle/juttle","owner":{"login":"juttle","id":8988633,"avatar_url":"https://avatars.githubusercontent.com/u/8988633?v=3","gravatar_id":"","url":"https://api.github.com/users/juttle","html_url":"https://github.com/juttle","followers_url":"https://api.github.com/users/juttle/followers","following_url":"https://api.github.com/users/juttle/following{/other_user}","gists_url":"https://api.github.com/users/juttle/gists{/gist_id}","starred_url":"https://api.github.com/users/juttle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juttle/subscriptions","organizations_url":"https://api.github.com/users/juttle/orgs","repos_url":"https://api.github.com/users/juttle/repos","events_url":"https://api.github.com/users/juttle/events{/privacy}","received_events_url":"https://api.github.com/users/juttle/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/juttle/juttle","description":"Juttle dataflow programming language","fork":false,"url":"https://api.github.com/repos/juttle/juttle","forks_url":"https://api.github.com/repos/juttle/juttle/forks","keys_url":"https://api.github.com/repos/juttle/juttle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juttle/juttle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juttle/juttle/teams","hooks_url":"https://api.github.com/repos/juttle/juttle/hooks","issue_events_url":"https://api.github.com/repos/juttle/juttle/issues/events{/number}","events_url":"https://api.github.com/repos/juttle/juttle/events","assignees_url":"https://api.github.com/repos/juttle/juttle/assignees{/user}","branches_url":"https://api.github.com/repos/juttle/juttle/branches{/branch}","tags_url":"https://api.github.com/repos/juttle/juttle/tags","blobs_url":"https://api.github.com/repos/juttle/juttle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juttle/juttle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juttle/juttle/git/refs{/sha}","trees_url":"https://api.github.com/repos/juttle/juttle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juttle/juttle/statuses/{sha}","languages_url":"https://api.github.com/repos/juttle/juttle/languages","stargazers_url":"https://api.github.com/repos/juttle/juttle/stargazers","contributors_url":"https://api.github.com/repos/juttle/juttle/contributors","subscribers_url":"https://api.github.com/repos/juttle/juttle/subscribers","subscription_url":"https://api.github.com/repos/juttle/juttle/subscription","commits_url":"https://api.github.com/repos/juttle/juttle/commits{/sha}","git_commits_url":"https://api.github.com/repos/juttle/juttle/git/commits{/sha}","comments_url":"https://api.github.com/repos/juttle/juttle/comments{/number}","issue_comment_url":"https://api.github.com/repos/juttle/juttle/issues/comments{/number}","contents_url":"https://api.github.com/repos/juttle/juttle/contents/{+path}","compare_url":"https://api.github.com/repos/juttle/juttle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juttle/juttle/merges","archive_url":"https://api.github.com/repos/juttle/juttle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juttle/juttle/downloads","issues_url":"https://api.github.com/repos/juttle/juttle/issues{/number}","pulls_url":"https://api.github.com/repos/juttle/juttle/pulls{/number}","milestones_url":"https://api.github.com/repos/juttle/juttle/milestones{/number}","notifications_url":"https://api.github.com/repos/juttle/juttle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juttle/juttle/labels{/name}","releases_url":"https://api.github.com/repos/juttle/juttle/releases{/id}","deployments_url":"https://api.github.com/repos/juttle/juttle/deployments","created_at":"2015-12-18T22:50:40Z","updated_at":"2016-03-22T16:16:33Z","pushed_at":"2016-03-22T16:54:40Z","git_url":"git://github.com/juttle/juttle.git","ssh_url":"git@github.com:juttle/juttle.git","clone_url":"https://github.com/juttle/juttle.git","svn_url":"https://github.com/juttle/juttle","homepage":"http://juttle.github.io/","size":5725,"stargazers_count":144,"watchers_count":144,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":9,"mirror_url":null,"open_issues_count":127,"forks":9,"open_issues":127,"watchers":144,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/juttle/juttle/pulls/641"},"html":{"href":"https://github.com/juttle/juttle/pull/641"},"issue":{"href":"https://api.github.com/repos/juttle/juttle/issues/641"},"comments":{"href":"https://api.github.com/repos/juttle/juttle/issues/641/comments"},"review_comments":{"href":"https://api.github.com/repos/juttle/juttle/pulls/641/comments"},"review_comment":{"href":"https://api.github.com/repos/juttle/juttle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/juttle/juttle/pulls/641/commits"},"statuses":{"href":"https://api.github.com/repos/juttle/juttle/statuses/1748ffe07dc4ca48155b40571e29b30809e57b3c"}}}}