{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback-next/issues/1396","repository_url":"https://api.github.com/repos/strongloop/loopback-next","labels_url":"https://api.github.com/repos/strongloop/loopback-next/issues/1396/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback-next/issues/1396/comments","events_url":"https://api.github.com/repos/strongloop/loopback-next/issues/1396/events","html_url":"https://github.com/strongloop/loopback-next/issues/1396","id":329727971,"node_id":"MDU6SXNzdWUzMjk3Mjc5NzE=","number":1396,"title":"How to modify datasource configuration in integration/acceptance tests","user":{"login":"bajtos","id":1140553,"node_id":"MDQ6VXNlcjExNDA1NTM=","avatar_url":"https://avatars1.githubusercontent.com/u/1140553?v=4","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false},"labels":[{"id":534463371,"node_id":"MDU6TGFiZWw1MzQ0NjMzNzE=","url":"https://api.github.com/repos/strongloop/loopback-next/labels/developer-experience","name":"developer-experience","color":"FF8000","default":false},{"id":534463431,"node_id":"MDU6TGFiZWw1MzQ0NjM0MzE=","url":"https://api.github.com/repos/strongloop/loopback-next/labels/feature","name":"feature","color":"c2e0c6","default":false},{"id":738709523,"node_id":"MDU6TGFiZWw3Mzg3MDk1MjM=","url":"https://api.github.com/repos/strongloop/loopback-next/labels/non-DP3","name":"non-DP3","color":"c5c5c5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-06T06:30:31Z","updated_at":"2018-06-12T18:56:43Z","closed_at":null,"author_association":"MEMBER","body":"When I wrote the original Thinking in LoopBack content, which was later converted to best-practices guides [Implementing features](http://loopback.io/doc/en/lb4/Implementing-features.html) and [Testing your Application](http://loopback.io/doc/en/lb4/Testing-your-application.html), I was thinking that acceptance and integration tests should use the very same datasource configuration as the actual application, to ensure that tests are testing the same database setup as will be used during app runtime.\r\n\r\nBased on our recent experience in #1385 and #1347, it's becoming clear that there are legitimate needs to slightly tweak datasource configuration in tests. For example:\r\n - When dealing with in-memory connector persisting data in a file, we may want to disable this persistence in tests by unsetting `file` property.\r\n - When running tests against a real database, we may want to use a different table name so that our tests are not touch the data used by the actual app.\r\n - When testing Service integration, we may want to configure caching proxy to speed up our test suite.\r\n\r\nLet's address these needs!\r\n\r\nWhat we need to figure out:\r\n\r\n - How to define datasources and repositories in such way that integration/acceptance tests and test-data builders can tweak the configuration.\r\n - How to write test-data builders in such way that tests can provide a modified datasource configuration. For example, test-data builders can accept a datasource instance or a repository instance initialized by the actual test to use the correct datasource configuration.\r\n - How to tweak datasource config in acceptance and integration tests and use that tweaked configuration for test-data builders too.\r\n \r\nLet's keep this issue focused on database-backed datasources only. Testing Services is out of scope, see #1311 for that.\r\n\r\n## Acceptance criteria\r\n\r\n - Update the content and code snippets in the following doc pages to show the new approach:\r\n   - [ ] [Implementing features](http://loopback.io/doc/en/lb4/Implementing-features.html) \r\n   - [ ] [Testing your Application](http://loopback.io/doc/en/lb4/Testing-your-application.html)\r\n - Update `examples/todo` to use the new approach\r\n - Update templates used by CLI to follow the new approach, especially the datasource template and possibly repository template (if it's implemented by the time we start working on this story)"},"comment":{"url":"https://api.github.com/repos/strongloop/loopback-next/issues/comments/396697130","html_url":"https://github.com/strongloop/loopback-next/issues/1396#issuecomment-396697130","issue_url":"https://api.github.com/repos/strongloop/loopback-next/issues/1396","id":396697130,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NjY5NzEzMA==","user":{"login":"jannyHou","id":12554153,"node_id":"MDQ6VXNlcjEyNTU0MTUz","avatar_url":"https://avatars0.githubusercontent.com/u/12554153?v=4","gravatar_id":"","url":"https://api.github.com/users/jannyHou","html_url":"https://github.com/jannyHou","followers_url":"https://api.github.com/users/jannyHou/followers","following_url":"https://api.github.com/users/jannyHou/following{/other_user}","gists_url":"https://api.github.com/users/jannyHou/gists{/gist_id}","starred_url":"https://api.github.com/users/jannyHou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jannyHou/subscriptions","organizations_url":"https://api.github.com/users/jannyHou/orgs","repos_url":"https://api.github.com/users/jannyHou/repos","events_url":"https://api.github.com/users/jannyHou/events{/privacy}","received_events_url":"https://api.github.com/users/jannyHou/received_events","type":"User","site_admin":false},"created_at":"2018-06-12T18:56:43Z","updated_at":"2018-06-12T18:56:43Z","author_association":"CONTRIBUTOR","body":"Comments from Raymond:\r\n- We want to generate datasource from environment.\r\n\r\nLet's discuss more about the detail of \"new approach\" then revisit this story.\r\nSome possibility of the \"new approach\":\r\n- create api to generate the datasource dynamically\r\n- provide env based settings, boot can pick up the config accordingly"}}
{"actor":{"display_login":"jannyHou"}}