mock_request 1.0.5

  • 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.5 #

  • Add toString to MockHttpHeaders.

1.0.4 #

  • Fix for ifModifiedSince

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.5

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.5 Feb 3, 2019 Go to the documentation of mock_request 1.0.5 Download mock_request 1.0.5 archive
1.0.4 Oct 21, 2018 Go to the documentation of mock_request 1.0.4 Download mock_request 1.0.4 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]
41
Health:
Code health derived from static analysis. [more]
94
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 Apr 25, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms: Flutter, other

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

Health suggestions

Fix lib/src/response.dart. (-2.48 points)

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

line 24 col 23: Use = to separate a named parameter from its default value.

line 40 col 3: Avoid return types on setters.

line 98 col 5: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 104 col 49: Use = to separate a named parameter from its default value.

line 115 col 18: Use = to separate a named parameter from its default value.

Fix lib/src/headers.dart. (-1.99 points)

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

line 17 col 3: Avoid return types on setters.

line 24 col 3: Avoid return types on setters.

line 31 col 3: Avoid return types on setters.

line 39 col 3: Avoid return types on setters.

Fix lib/src/request.dart. (-1.49 points)

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

line 43 col 23: Use = to separate a named parameter from its default value.

line 72 col 3: Avoid return types on setters.

line 112 col 5: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

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
Dev dependencies
angel_framework ^2.0.0-alpha
http ^0.11.0
test ^1.0.0