platform/test/repeat_request_test.dart

30 lines
979 B
Dart
Raw Normal View History

2017-08-28 15:29:27 +00:00
import 'dart:async';
import 'package:angel_framework/angel_framework.dart';
2018-06-08 07:06:26 +00:00
import 'package:dart2_constant/convert.dart';
2017-08-28 15:29:27 +00:00
import 'package:mock_request/mock_request.dart';
import 'package:test/test.dart';
main() {
MockHttpRequest mk(int id) {
return new MockHttpRequest('GET', Uri.parse('/test/$id'))..close();
}
test('can request the same url twice', () async {
var app = new Angel()..get('/test/:id', (id) => 'Hello $id');
var rq1 = mk(1), rq2 = mk(2), rq3 = mk(1);
2018-02-07 05:36:24 +00:00
await Future.wait([rq1, rq2, rq3].map(new AngelHttp(app).handleRequest));
2018-06-08 07:06:26 +00:00
var body1 = await rq1.response.transform(utf8.decoder).join(),
body2 = await rq2.response.transform(utf8.decoder).join(),
body3 = await rq3.response.transform(utf8.decoder).join();
2017-08-28 15:29:27 +00:00
print('Response #1: $body1');
print('Response #2: $body2');
print('Response #3: $body3');
expect(
body1,
allOf(
isNot(body2),
equals(body3),
));
});
}