{"action":"created","comment":{"url":"https://api.github.com/repos/spotify/flo/pulls/comments/203227753","pull_request_review_id":138075340,"id":203227753,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMzIyNzc1Mw==","diff_hunk":"@@ -371,6 +387,137 @@ public void tasksRunInProcesses() throws Exception {\n     assertThat(uniqueJvms, not(contains(mainJvm)));\n   }\n \n+  @Test\n+  public void isTestShouldBeTrueInTestScope() throws Exception {\n+    try (TestScope ts = FloTesting.scope()) {\n+      final Task<Boolean> isTest = Task.named(\"task\").ofType(Boolean.class)\n+          .process(FloTesting::isTest);","path":"flo-runner/src/test/java/com/spotify/flo/context/FloRunnerTest.java","position":62,"original_position":62,"commit_id":"fbdc169ae3d94e9ee618ac99f23f3f89604ac437","original_commit_id":"fbdc169ae3d94e9ee618ac99f23f3f89604ac437","user":{"login":"danielnorberg","id":393289,"node_id":"MDQ6VXNlcjM5MzI4OQ==","avatar_url":"https://avatars1.githubusercontent.com/u/393289?v=4","gravatar_id":"","url":"https://api.github.com/users/danielnorberg","html_url":"https://github.com/danielnorberg","followers_url":"https://api.github.com/users/danielnorberg/followers","following_url":"https://api.github.com/users/danielnorberg/following{/other_user}","gists_url":"https://api.github.com/users/danielnorberg/gists{/gist_id}","starred_url":"https://api.github.com/users/danielnorberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielnorberg/subscriptions","organizations_url":"https://api.github.com/users/danielnorberg/orgs","repos_url":"https://api.github.com/users/danielnorberg/repos","events_url":"https://api.github.com/users/danielnorberg/events{/privacy}","received_events_url":"https://api.github.com/users/danielnorberg/received_events","type":"User","site_admin":false},"body":"This works because `AsyncContext` [propagates](https://github.com/spotify/flo/blob/master/flo-workflow/src/main/java/com/spotify/flo/context/AsyncContext.java#L47) the grpc `Context` to worker threads.","created_at":"2018-07-18T01:21:59Z","updated_at":"2018-07-18T01:21:59Z","html_url":"https://github.com/spotify/flo/pull/108#discussion_r203227753","pull_request_url":"https://api.github.com/repos/spotify/flo/pulls/108","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/spotify/flo/pulls/comments/203227753"},"html":{"href":"https://github.com/spotify/flo/pull/108#discussion_r203227753"},"pull_request":{"href":"https://api.github.com/repos/spotify/flo/pulls/108"}},"in_reply_to_id":202939601},"pull_request":{"url":"https://api.github.com/repos/spotify/flo/pulls/108","id":201855476,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAxODU1NDc2","html_url":"https://github.com/spotify/flo/pull/108","diff_url":"https://github.com/spotify/flo/pull/108.diff","patch_url":"https://github.com/spotify/flo/pull/108.patch","issue_url":"https://api.github.com/repos/spotify/flo/issues/108","number":108,"state":"open","locked":false,"title":"wip: test mode","user":{"login":"danielnorberg","id":393289,"node_id":"MDQ6VXNlcjM5MzI4OQ==","avatar_url":"https://avatars1.githubusercontent.com/u/393289?v=4","gravatar_id":"","url":"https://api.github.com/users/danielnorberg","html_url":"https://github.com/danielnorberg","followers_url":"https://api.github.com/users/danielnorberg/followers","following_url":"https://api.github.com/users/danielnorberg/following{/other_user}","gists_url":"https://api.github.com/users/danielnorberg/gists{/gist_id}","starred_url":"https://api.github.com/users/danielnorberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielnorberg/subscriptions","organizations_url":"https://api.github.com/users/danielnorberg/orgs","repos_url":"https://api.github.com/users/danielnorberg/repos","events_url":"https://api.github.com/users/danielnorberg/events{/privacy}","received_events_url":"https://api.github.com/users/danielnorberg/received_events","type":"User","site_admin":false},"body":"Flo workflows can be run in a \"test mode\" without having to modify the existing workflow code:\r\n```java\r\nfinal Task<Boolean> task = Task.named(\"task\").ofType(Boolean.class)\r\n    .process(() -> {\r\n      // FloTesting.isTest() == true if run in test mode\r\n    });\r\n\r\ntry (TestScope ts = FloTesting.scope()) {\r\n  // FloTesting.isTest() == true\r\n  FloRunner.runTask(task).future().get();\r\n}\r\n```\r\n\r\n`TaskContext` implementations can check whether they are running under test using `FloTesting.isTest()` and change their behavior accordingly. Mock values etc can be stored in the test context using `TestContext.key()` & friends. This is intended for e.g. our internal flo libraries to interact with, not user code directly. Flo libraries should wrap their use of `TestContext` and provide easy to use primitives. E.g.:\r\n\r\n```java\r\ntry (TestScope ts = FloTesting.scope()) {\r\n  StorageLookup.mock().mockValue(\"bar\", \"17\");\r\n  \r\n  final Task<String> task = Task.named(\"task\").ofType(String.class)\r\n      .input(StorageLookup.of(\"bar\"))\r\n      .context(new PublishingContext(\"foo\"))\r\n      .process((bar, result) -> {\r\n        // Do some processing and produce a value\r\n        return result.publish(processData(bar));\r\n      });\r\n\r\n  assertThat(runTask(task).future().get(30, SECONDS), is(\"42\"));\r\n\r\n  assertThat(StorageLookup.mock().lookups(\"bar\"), is(1));\r\n  assertThat(PublishingContext.mock().lookups(\"foo\"), is(1));\r\n  assertThat(PublishingContext.mock().published(\"foo\"), contains(\"42\"));\r\n}\r\n```\r\n\r\nIn scala:\r\n```scala\r\nflo.test(() => {\r\n  ...\r\n})\r\n```\r\n","created_at":"2018-07-17T08:03:29Z","updated_at":"2018-07-18T01:21:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fcfafd403ff9ec123a910e8b1c44d9dba91e99d0","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/spotify/flo/pulls/108/commits","review_comments_url":"https://api.github.com/repos/spotify/flo/pulls/108/comments","review_comment_url":"https://api.github.com/repos/spotify/flo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spotify/flo/issues/108/comments","statuses_url":"https://api.github.com/repos/spotify/flo/statuses/fbdc169ae3d94e9ee618ac99f23f3f89604ac437","head":{"label":"spotify:testing","ref":"testing","sha":"fbdc169ae3d94e9ee618ac99f23f3f89604ac437","user":{"login":"spotify","id":251374,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTM3NA==","avatar_url":"https://avatars2.githubusercontent.com/u/251374?v=4","gravatar_id":"","url":"https://api.github.com/users/spotify","html_url":"https://github.com/spotify","followers_url":"https://api.github.com/users/spotify/followers","following_url":"https://api.github.com/users/spotify/following{/other_user}","gists_url":"https://api.github.com/users/spotify/gists{/gist_id}","starred_url":"https://api.github.com/users/spotify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spotify/subscriptions","organizations_url":"https://api.github.com/users/spotify/orgs","repos_url":"https://api.github.com/users/spotify/repos","events_url":"https://api.github.com/users/spotify/events{/privacy}","received_events_url":"https://api.github.com/users/spotify/received_events","type":"Organization","site_admin":false},"repo":{"id":46450575,"node_id":"MDEwOlJlcG9zaXRvcnk0NjQ1MDU3NQ==","name":"flo","full_name":"spotify/flo","owner":{"login":"spotify","id":251374,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTM3NA==","avatar_url":"https://avatars2.githubusercontent.com/u/251374?v=4","gravatar_id":"","url":"https://api.github.com/users/spotify","html_url":"https://github.com/spotify","followers_url":"https://api.github.com/users/spotify/followers","following_url":"https://api.github.com/users/spotify/following{/other_user}","gists_url":"https://api.github.com/users/spotify/gists{/gist_id}","starred_url":"https://api.github.com/users/spotify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spotify/subscriptions","organizations_url":"https://api.github.com/users/spotify/orgs","repos_url":"https://api.github.com/users/spotify/repos","events_url":"https://api.github.com/users/spotify/events{/privacy}","received_events_url":"https://api.github.com/users/spotify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spotify/flo","description":"A lightweight workflow definition library","fork":false,"url":"https://api.github.com/repos/spotify/flo","forks_url":"https://api.github.com/repos/spotify/flo/forks","keys_url":"https://api.github.com/repos/spotify/flo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spotify/flo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spotify/flo/teams","hooks_url":"https://api.github.com/repos/spotify/flo/hooks","issue_events_url":"https://api.github.com/repos/spotify/flo/issues/events{/number}","events_url":"https://api.github.com/repos/spotify/flo/events","assignees_url":"https://api.github.com/repos/spotify/flo/assignees{/user}","branches_url":"https://api.github.com/repos/spotify/flo/branches{/branch}","tags_url":"https://api.github.com/repos/spotify/flo/tags","blobs_url":"https://api.github.com/repos/spotify/flo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spotify/flo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spotify/flo/git/refs{/sha}","trees_url":"https://api.github.com/repos/spotify/flo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spotify/flo/statuses/{sha}","languages_url":"https://api.github.com/repos/spotify/flo/languages","stargazers_url":"https://api.github.com/repos/spotify/flo/stargazers","contributors_url":"https://api.github.com/repos/spotify/flo/contributors","subscribers_url":"https://api.github.com/repos/spotify/flo/subscribers","subscription_url":"https://api.github.com/repos/spotify/flo/subscription","commits_url":"https://api.github.com/repos/spotify/flo/commits{/sha}","git_commits_url":"https://api.github.com/repos/spotify/flo/git/commits{/sha}","comments_url":"https://api.github.com/repos/spotify/flo/comments{/number}","issue_comment_url":"https://api.github.com/repos/spotify/flo/issues/comments{/number}","contents_url":"https://api.github.com/repos/spotify/flo/contents/{+path}","compare_url":"https://api.github.com/repos/spotify/flo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spotify/flo/merges","archive_url":"https://api.github.com/repos/spotify/flo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spotify/flo/downloads","issues_url":"https://api.github.com/repos/spotify/flo/issues{/number}","pulls_url":"https://api.github.com/repos/spotify/flo/pulls{/number}","milestones_url":"https://api.github.com/repos/spotify/flo/milestones{/number}","notifications_url":"https://api.github.com/repos/spotify/flo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spotify/flo/labels{/name}","releases_url":"https://api.github.com/repos/spotify/flo/releases{/id}","deployments_url":"https://api.github.com/repos/spotify/flo/deployments","created_at":"2015-11-18T22:06:27Z","updated_at":"2018-07-12T07:57:37Z","pushed_at":"2018-07-17T08:03:30Z","git_url":"git://github.com/spotify/flo.git","ssh_url":"git@github.com:spotify/flo.git","clone_url":"https://github.com/spotify/flo.git","svn_url":"https://github.com/spotify/flo","homepage":"http://spotify.github.io/flo/maven/latest/","size":7811,"stargazers_count":40,"watchers_count":40,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":12,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":12,"open_issues":9,"watchers":40,"default_branch":"master"}},"base":{"label":"spotify:master","ref":"master","sha":"ed62b2c1f54efe8ed4850e0c762cbf47fdd222c9","user":{"login":"spotify","id":251374,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTM3NA==","avatar_url":"https://avatars2.githubusercontent.com/u/251374?v=4","gravatar_id":"","url":"https://api.github.com/users/spotify","html_url":"https://github.com/spotify","followers_url":"https://api.github.com/users/spotify/followers","following_url":"https://api.github.com/users/spotify/following{/other_user}","gists_url":"https://api.github.com/users/spotify/gists{/gist_id}","starred_url":"https://api.github.com/users/spotify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spotify/subscriptions","organizations_url":"https://api.github.com/users/spotify/orgs","repos_url":"https://api.github.com/users/spotify/repos","events_url":"https://api.github.com/users/spotify/events{/privacy}","received_events_url":"https://api.github.com/users/spotify/received_events","type":"Organization","site_admin":false},"repo":{"id":46450575,"node_id":"MDEwOlJlcG9zaXRvcnk0NjQ1MDU3NQ==","name":"flo","full_name":"spotify/flo","owner":{"login":"spotify","id":251374,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTM3NA==","avatar_url":"https://avatars2.githubusercontent.com/u/251374?v=4","gravatar_id":"","url":"https://api.github.com/users/spotify","html_url":"https://github.com/spotify","followers_url":"https://api.github.com/users/spotify/followers","following_url":"https://api.github.com/users/spotify/following{/other_user}","gists_url":"https://api.github.com/users/spotify/gists{/gist_id}","starred_url":"https://api.github.com/users/spotify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spotify/subscriptions","organizations_url":"https://api.github.com/users/spotify/orgs","repos_url":"https://api.github.com/users/spotify/repos","events_url":"https://api.github.com/users/spotify/events{/privacy}","received_events_url":"https://api.github.com/users/spotify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spotify/flo","description":"A lightweight workflow definition library","fork":false,"url":"https://api.github.com/repos/spotify/flo","forks_url":"https://api.github.com/repos/spotify/flo/forks","keys_url":"https://api.github.com/repos/spotify/flo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spotify/flo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spotify/flo/teams","hooks_url":"https://api.github.com/repos/spotify/flo/hooks","issue_events_url":"https://api.github.com/repos/spotify/flo/issues/events{/number}","events_url":"https://api.github.com/repos/spotify/flo/events","assignees_url":"https://api.github.com/repos/spotify/flo/assignees{/user}","branches_url":"https://api.github.com/repos/spotify/flo/branches{/branch}","tags_url":"https://api.github.com/repos/spotify/flo/tags","blobs_url":"https://api.github.com/repos/spotify/flo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spotify/flo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spotify/flo/git/refs{/sha}","trees_url":"https://api.github.com/repos/spotify/flo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spotify/flo/statuses/{sha}","languages_url":"https://api.github.com/repos/spotify/flo/languages","stargazers_url":"https://api.github.com/repos/spotify/flo/stargazers","contributors_url":"https://api.github.com/repos/spotify/flo/contributors","subscribers_url":"https://api.github.com/repos/spotify/flo/subscribers","subscription_url":"https://api.github.com/repos/spotify/flo/subscription","commits_url":"https://api.github.com/repos/spotify/flo/commits{/sha}","git_commits_url":"https://api.github.com/repos/spotify/flo/git/commits{/sha}","comments_url":"https://api.github.com/repos/spotify/flo/comments{/number}","issue_comment_url":"https://api.github.com/repos/spotify/flo/issues/comments{/number}","contents_url":"https://api.github.com/repos/spotify/flo/contents/{+path}","compare_url":"https://api.github.com/repos/spotify/flo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spotify/flo/merges","archive_url":"https://api.github.com/repos/spotify/flo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spotify/flo/downloads","issues_url":"https://api.github.com/repos/spotify/flo/issues{/number}","pulls_url":"https://api.github.com/repos/spotify/flo/pulls{/number}","milestones_url":"https://api.github.com/repos/spotify/flo/milestones{/number}","notifications_url":"https://api.github.com/repos/spotify/flo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spotify/flo/labels{/name}","releases_url":"https://api.github.com/repos/spotify/flo/releases{/id}","deployments_url":"https://api.github.com/repos/spotify/flo/deployments","created_at":"2015-11-18T22:06:27Z","updated_at":"2018-07-12T07:57:37Z","pushed_at":"2018-07-17T08:03:30Z","git_url":"git://github.com/spotify/flo.git","ssh_url":"git@github.com:spotify/flo.git","clone_url":"https://github.com/spotify/flo.git","svn_url":"https://github.com/spotify/flo","homepage":"http://spotify.github.io/flo/maven/latest/","size":7811,"stargazers_count":40,"watchers_count":40,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":12,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":12,"open_issues":9,"watchers":40,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spotify/flo/pulls/108"},"html":{"href":"https://github.com/spotify/flo/pull/108"},"issue":{"href":"https://api.github.com/repos/spotify/flo/issues/108"},"comments":{"href":"https://api.github.com/repos/spotify/flo/issues/108/comments"},"review_comments":{"href":"https://api.github.com/repos/spotify/flo/pulls/108/comments"},"review_comment":{"href":"https://api.github.com/repos/spotify/flo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spotify/flo/pulls/108/commits"},"statuses":{"href":"https://api.github.com/repos/spotify/flo/statuses/fbdc169ae3d94e9ee618ac99f23f3f89604ac437"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"danielnorberg"}}