mockable_filesystem 0.0.3

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 21

mockable_filesystem

Provides a FileSystem factory class for allocating File, Directory and Link objects, with two implementations - one which in turn returns the real objects from dart:io, and one which returns mock versions. This allows tests to be written that make use of files and directories without having to create them on disk. The mock File/Directory/Link classes are not complete, but have sufficient functionality to work in most cases. The ultimate aim is to have complete mock implementations, as well as the ability to mock Windows file systems on Linux/Mac and vice-versa, to help with testing code for cross-platform correctness.

Installing

  1. Depend on it

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

    dependencies:
      mockable_filesystem: any
    

    If your package is an application package you should use any as the version constraint.

  2. Install it

    If you're using the Dart Editor, choose:

    Menu > Tools > Pub Install
    

    Or if you want to install from the command line, run:

    $ pub install
    
  3. Import it

    Now in your Dart code, you can use:

    import 'package:mockable_filesystem/filesystem.dart';
    

    or:

    import 'package:mockable_filesystem/mock_filesystem.dart';
    

0.0.3

  • Use FileSystemException in all appropriate places to follow the change to dart:io

Use this package as a library

1. Depend on it

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


dependencies:
  mockable_filesystem: ^0.0.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:mockable_filesystem/filesystem.dart';
import 'package:mockable_filesystem/mock_filesystem.dart';
  
Version Uploaded Documentation Archive
0.0.3 Sep 23, 2014 Go to the documentation of mockable_filesystem 0.0.3 Download mockable_filesystem 0.0.3 archive
0.0.1 Jul 24, 2013 Go to the documentation of mockable_filesystem 0.0.1 Download mockable_filesystem 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
43
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
21
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: unsure

Error(s) prevent platform classification:

Error(s) in lib/mock_filesystem.dart: super call must be last in an initializer list (see https://goo.gl/EY6hDP): 'super(filepath, FileSystemEntityType.FILE)'.

Issues and suggestions

Fix lib/mock_filesystem.dart.

Analysis of lib/mock_filesystem.dart failed with 21 errors, 14 hints, including:

line 53 col 50: Static method 'type' can't be accessed through an instance.

line 65 col 5: super call must be last in an initializer list (see https://goo.gl/EY6hDP): 'super(filepath, FileSystemEntityType.FILE)'.

line 68 col 3: Invalid override. The type of 'MockFile.createSync' ('() → void') isn't a subtype of 'File.createSync' ('({recursive: bool}) → void').

line 72 col 3: Invalid override. The type of 'MockFile.create' ('() → Future<File>') isn't a subtype of 'File.create' ('({recursive: bool}) → Future<File>').

line 77 col 3: Invalid override. The type of 'MockFile.deleteSync' ('() → void') isn't a subtype of 'FileSystemEntity.deleteSync' ('({recursive: bool}) → void').

Fix lib/filesystem.dart.

Analysis of lib/filesystem.dart failed with 1 error, 1 hint:

line 42 col 15: The method 'createRecursivelySync' isn't defined for the class 'Directory'.

line 3 col 8: Unused import: 'dart:async'.

Fix platform conflicts.

Error(s) prevent platform classification:

Error(s) in lib/mock_filesystem.dart: super call must be last in an initializer list (see https://goo.gl/EY6hDP): 'super(filepath, FileSystemEntityType.FILE)'.

Running dartdoc failed.

Make sure dartdoc runs without any issues.

Use constrained dependencies.

The pubspec.yaml contains 2 dependencies without version constraints. Specify version ranges for the following dependencies: logging, path.

Add SDK constraint in pubspec.yaml.

For information about setting SDK constraint, please see https://www.dartlang.org/tools/pub/pubspec#sdk-constraints.

Package is too old.

The package was released more than two years ago.

Package is pre-v1 release.

While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction of the API.

The description is too long.

Search engines will display only the first part of the description. Try to keep it under 180 characters.

Maintain an example.

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use mockable_filesystem.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
logging >=0.6.5 0.11.3+2
path >=0.6.5 1.6.2
Dev dependencies
unittest >=0.6.5