Skip to content

Commit

Permalink
Update cronet_configuration_test.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 authored Nov 24, 2023
1 parent a331912 commit f6a3d51
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:convert';
import 'dart:io';

import 'package:cronet_http/cronet_http.dart';
import 'package:http/http.dart';
import 'package:integration_test/integration_test.dart';
import 'package:test/test.dart';

Expand Down Expand Up @@ -92,6 +94,49 @@ void testInvalidConfigurations() {
});
}

void testMethods() {
group('methods', () {
late HttpServer server;
late String requestMethod;

setUp(() async {
server = (await HttpServer.bind('localhost', 0))
..listen((request) async {
await request.drain<void>();
requestMethod = request.method;
await request.response.close();
});
});
tearDown(() {
server.close();
});

test('methods', () async {
final engine = CronetEngine.build();
const methods = [
'GET',
'HEAD',
'POST',
'PUT',
'DELETE',
'CONNECT',
'OPTIONS',
'TRACE',
'PATCH',
'CUSTOM',
];
for (final method in methods) {
final request = Request(
method,
Uri.parse('http://localhost:${server.port}'),
);
await CronetClient.fromCronetEngine(engine).send(request);
expect(requestMethod, method);
}
});
});
}

void testUserAgent() {
group('userAgent', () {
late HttpServer server;
Expand Down

0 comments on commit f6a3d51

Please sign in to comment.