mock_request 1.0.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 69

mock_request

Pub build status

Manufacture dart:io HttpRequests, HttpResponses, HttpHeaders, etc. This makes it possible to test server-side Dart applications without having to ever bind to a port.

This package was originally designed to testing Angel applications smoother, but works with any Dart-based server. :)

Usage

var rq = new MockHttpRequest('GET', Uri.parse('/foo'));
await rq.close();
await app.handleRequest(rq); // Run within your server-side application
var rs = rq.response;
expect(rs.statusCode, equals(200));
expect(await rs.transform(UTF8.decoder).join(),
    equals(JSON.encode('Hello, world!')));

More examples can be found in the included tests.

1.0.3

  • Dart2 fixes
  • Apparently fix hangs that break Angel tests

example/main.dart

import 'package:mock_request/mock_request.dart';

main() async {
  var rq = new MockHttpRequest('GET', Uri.parse('/foo'));
  await rq.close();
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  mock_request: ^1.0.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:mock_request/mock_request.dart';
  
Version Uploaded Documentation Archive
1.0.3 May 16, 2018 Go to the documentation of mock_request 1.0.3 Download mock_request 1.0.3 archive
1.0.2 Jul 2, 2017 Go to the documentation of mock_request 1.0.2 Download mock_request 1.0.2 archive
1.0.1 Jun 12, 2017 Go to the documentation of mock_request 1.0.1 Download mock_request 1.0.1 archive
1.0.0 Mar 25, 2017 Go to the documentation of mock_request 1.0.0 Download mock_request 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
40
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
69
Learn more about scoring.

We analyzed this package on Aug 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.11.8

Platforms

Detected platforms: Flutter, other

Primary library: package:mock_request/mock_request.dart with components: io.

Suggestions

Fix lib/src/headers.dart.

Analysis of lib/src/headers.dart reported 3 hints:

line 10 col 39: 'CONTENT_TYPE' is deprecated and shouldn't be used.

line 11 col 50: 'CONTENT_TYPE' is deprecated and shouldn't be used.

line 17 col 23: 'CONTENT_TYPE' is deprecated and shouldn't be used.

Fix lib/src/response.dart.

Analysis of lib/src/response.dart reported 3 hints:

line 20 col 65: 'ANY_IP_V4' is deprecated and shouldn't be used.

line 115 col 31: 'MOVED_TEMPORARILY' is deprecated and shouldn't be used.

line 116 col 39: 'MOVED_TEMPORARILY' is deprecated and shouldn't be used.

Fix lib/src/request.dart.

Analysis of lib/src/request.dart reported 1 hint:

line 24 col 65: 'LOOPBACK_IP_V4' is deprecated and shouldn't be used.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
charcode >=1.0.0 <2.0.0 1.1.2
dart2_constant ^1.0.0 1.0.2+dart2
Dev dependencies
angel_framework >=1.0.0-dev <2.0.0
http >=0.11.3 <0.12.0
test >=0.12.0 <0.13.0