{"action":"created","issue":{"url":"https://api.github.com/repos/stablekernel/aqueduct/issues/108","repository_url":"https://api.github.com/repos/stablekernel/aqueduct","labels_url":"https://api.github.com/repos/stablekernel/aqueduct/issues/108/labels{/name}","comments_url":"https://api.github.com/repos/stablekernel/aqueduct/issues/108/comments","events_url":"https://api.github.com/repos/stablekernel/aqueduct/issues/108/events","html_url":"https://github.com/stablekernel/aqueduct/issues/108","id":186850956,"number":108,"title":"Best practices for POST and related tests","user":{"login":"kbirch","id":245460,"avatar_url":"https://avatars.githubusercontent.com/u/245460?v=3","gravatar_id":"","url":"https://api.github.com/users/kbirch","html_url":"https://github.com/kbirch","followers_url":"https://api.github.com/users/kbirch/followers","following_url":"https://api.github.com/users/kbirch/following{/other_user}","gists_url":"https://api.github.com/users/kbirch/gists{/gist_id}","starred_url":"https://api.github.com/users/kbirch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbirch/subscriptions","organizations_url":"https://api.github.com/users/kbirch/orgs","repos_url":"https://api.github.com/users/kbirch/repos","events_url":"https://api.github.com/users/kbirch/events{/privacy}","received_events_url":"https://api.github.com/users/kbirch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-02T16:27:45Z","updated_at":"2016-11-02T17:12:22Z","closed_at":null,"body":"Greetings:\r\n\r\nA bit of a 2 part issue / question around the same topic...\r\n\r\n1 - I may have missed documentation examples somewhere about this, but what I put together seems to be working.  For a POST endpoint I'm just doing this inside my Controller class to get at the data I'm receiving:\r\n\r\n```\r\nawait request.decodeBody();\r\nMap body = request.requestBodyObject;\r\n```\r\n\r\nFirst question is, all good here?\r\n\r\n2 - The main reason I'm asking is because I get major failure when I run this through a test case, unless I comment out the first line completely (decodeBody()).  Here's the error:\r\n\r\n```\r\nExpected: \r\n\tStatus Code: 200\r\n\tBody: 'OK'\r\n  Actual: TestResponse:<\r\n\tStatus Code: 500\r\n\tHeaders: x-frame-options: SAMEORIGIN\r\n\t\t\t content-type: application/json; charset=utf-8\r\n\t\t\t x-xss-protection: 1; mode=block\r\n\t\t\t x-content-type-options: nosniff\r\n\t\t\t server: aqueduct/1\r\n\t\t\t content-length: 0\r\n\tBody: null>\r\n   Which: Status Code 200 != 500\r\n\r\npackage:test                                       expect\r\ntest/facebook_controller_test.dart 38:7            main.<async>.<fn>.<fn>.<async>\r\ndart:async                                         _SyncCompleter.complete\r\npackage:aqueduct/utilities/test_client.dart 279:5  TestRequest._executeRequest.<async>\r\ndart:async                                         _SyncCompleter.complete\r\npackage:aqueduct/utilities/test_client.dart 354:3  TestResponse._decodeBody.<async>\r\n===== asynchronous gap ===========================\r\ndart:async                                         _Completer.completeError\r\ntest/facebook_controller_test.dart 39:6            main.<async>.<fn>.<fn>.<async>\r\ndart:async                                         _SyncCompleter.complete\r\npackage:aqueduct/utilities/test_client.dart 279:5  TestRequest._executeRequest.<async>\r\ndart:async                                         _SyncCompleter.complete\r\npackage:aqueduct/utilities/test_client.dart 354:3  TestResponse._decodeBody.<async>\r\n```\r\n\r\nThe code comments in request.dart indicate the need to call decodeBody() first and it does work just fine on a deployed server, but the test fail is a bit of a nuisance requiring manual edits before running the test.  Is this a bug or am I doing something wrong?\r\n\r\nAlso, I can't get any custom logging to work at all in my controller classes when running through a test case - everything from trying to log to a remote system like Rollbar through to just a standard print statement.  That also works fine when deployed but just not when running a test. Any recommendations on how to approach that?  The issue above was pretty tough to diagnose without having any logging capabilities in my Controller code during a test run.\r\n\r\nThanks in advance!"},"comment":{"url":"https://api.github.com/repos/stablekernel/aqueduct/issues/comments/257932534","html_url":"https://github.com/stablekernel/aqueduct/issues/108#issuecomment-257932534","issue_url":"https://api.github.com/repos/stablekernel/aqueduct/issues/108","id":257932534,"user":{"login":"joeconwaystk","id":1576234,"avatar_url":"https://avatars.githubusercontent.com/u/1576234?v=3","gravatar_id":"","url":"https://api.github.com/users/joeconwaystk","html_url":"https://github.com/joeconwaystk","followers_url":"https://api.github.com/users/joeconwaystk/followers","following_url":"https://api.github.com/users/joeconwaystk/following{/other_user}","gists_url":"https://api.github.com/users/joeconwaystk/gists{/gist_id}","starred_url":"https://api.github.com/users/joeconwaystk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeconwaystk/subscriptions","organizations_url":"https://api.github.com/users/joeconwaystk/orgs","repos_url":"https://api.github.com/users/joeconwaystk/repos","events_url":"https://api.github.com/users/joeconwaystk/events{/privacy}","received_events_url":"https://api.github.com/users/joeconwaystk/received_events","type":"User","site_admin":false},"created_at":"2016-11-02T17:12:22Z","updated_at":"2016-11-02T17:12:22Z","body":"1. Are you using HTTPController? HTTPController decodes the body as part of its processing, so by the time you get your responder method invoked, requestBodyObject is already valid.\r\n\r\n2. Are you testing in IntelliJ IDEA? It sometimes doesn't pick up standard output, which is really a pain. Running tests from the terminal (pub run test -j 1) is what I do when it fails to pick up stdout. It's really obnoxious when you want to see the stack trace of the server itself, which is often. There is a flag on RequestController for this purpose, `includeErrorDetailsInServerErrorResponses`, which if true, returns the stack trace of a 500 in the JSON body."}}
{"actor":{"display_login":"joeconwaystk"}}