Skip to content

Commit

Permalink
Add rawResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
f3ath committed Aug 30, 2024
1 parent a07ef8e commit 24fc36b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/src/client/response/request_failure.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ class RequestFailure implements Exception {

@override
String toString() =>
'JSON:API request failed with HTTP status ${httpResponse.statusCode}.';
'JSON:API request failed with HTTP status ${rawResponse.httpResponse.statusCode}.';
}
4 changes: 2 additions & 2 deletions test/contract/crud_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void main() {
Include(['author', 'comments', 'comments.author'])
]);

expect(response.httpResponse.statusCode, 200);
expect(response.rawResponse.httpResponse.statusCode, 200);
expect(response.collection.length, 1);
expect(response.included.length, 3);

Expand Down Expand Up @@ -175,7 +175,7 @@ void main() {
await action();
fail('Exception expected');
} on RequestFailure catch (e) {
expect(e.httpResponse.statusCode, 404);
expect(e.rawResponse.httpResponse.statusCode, 404);
}
}
});
Expand Down
12 changes: 6 additions & 6 deletions test/contract/resource_creation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ void main() {
test('Resource id assigned on the server', () async {
await client
.createNew('posts', attributes: {'title': 'Hello world'}).then((r) {
expect(r.httpResponse.statusCode, 201);
expect(r.httpResponse.headers['location'], ['/posts/${r.resource.id}']);
expect(r.rawResponse.httpResponse.statusCode, 201);
expect(r.rawResponse.httpResponse.headers['location'], ['/posts/${r.resource.id}']);
expect(r.links['self'].toString(), '/posts/${r.resource.id}');
expect(r.resource.type, 'posts');
expect(r.resource.attributes['title'], 'Hello world');
Expand All @@ -30,8 +30,8 @@ void main() {
lid: 'lid',
attributes: {'title': 'Hello world'},
one: {'self': LocalIdentifier('posts', 'lid')}).then((r) {
expect(r.httpResponse.statusCode, 201);
expect(r.httpResponse.headers['location'], ['/posts/${r.resource.id}']);
expect(r.rawResponse.httpResponse.statusCode, 201);
expect(r.rawResponse.httpResponse.headers['location'], ['/posts/${r.resource.id}']);
expect(r.links['self'].toString(), '/posts/${r.resource.id}');
expect(r.resource.type, 'posts');
expect(r.resource.attributes['title'], 'Hello world');
Expand All @@ -42,9 +42,9 @@ void main() {
test('Resource id assigned on the client', () async {
await client.create('posts', '12345',
attributes: {'title': 'Hello world'}).then((r) {
expect(r.httpResponse.statusCode, 204);
expect(r.rawResponse.httpResponse.statusCode, 204);
expect(r.resource, isNull);
expect(r.httpResponse.headers['location'], isNull);
expect(r.rawResponse.httpResponse.headers['location'], isNull);
});
});
});
Expand Down

0 comments on commit 24fc36b

Please sign in to comment.