-
-
Notifications
You must be signed in to change notification settings - Fork 24
add meta parameter for createResourceAt() #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -66,7 +66,7 @@ class JsonApiClient { | |||
/// | |||
/// https://jsonapi.org/format/#crud-creating | |||
Future<Response<ResourceData>> createResourceAt(Uri uri, Resource resource, | |||
{Map<String, String> headers}) => | |||
{Map<String, String> headers, Map<String, Object> meta}) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the argument is not passed down to _resourceDoc()
.
Please add a unit test supporting this change. It would belong in this folder https://github.com/f3ath/json-api-dart/tree/master/test/unit/client
You can use the ones that are there already as an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, i will fix it, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should I use naming documentMeta replace meta? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Please disregard that comment. I removed it once realized that resource meta would be in the resource object itself. So just meta is OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get it!
final base = Uri(scheme: 'http', host: host, port: port); | ||
final routing = StandardRouting(base); | ||
|
||
group('Client-generated ID', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description does not reflect the intention of the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get it!
JsonApiClient client; | ||
RoutingClient routingClient; | ||
|
||
setUp(() async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use this one as the example https://github.com/f3ath/json-api-dart/blob/master/test/unit/client/conrner_cases_test.dart
There is no need to start an actual server for this test. You may use the TestHttpHandler
to simulate the response. Then use the TestHttpHandler.requestLog
property to validate the request (check that the document actually has the meta property).
I understand it can be confusing. Feel free to reach out if you have questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have done with TestHttpHandler. Thanks a lot 👍
expect(request, isNotNull); | ||
expect(request.uri, uri); | ||
expect(request.method, 'POST'); | ||
expect(request.body, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave just this expect
. The others are unrelated to this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Resource('people', '123', attributes: {'name': 'Te Cheng Hung'}); | ||
final meta = {'friend': 'Martin Fowler'}; | ||
|
||
handler.nextResponse = HttpResponse(500, body: 'Something went wrong'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're testing a successful case, so why use an error response? Why don't we use a simple 201 with no body?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I will fix that, thanks!
Almost there :) |
close #105 , for add meta parameter for createResourceAt().