Skip to content

Commit 14ba9ef

Browse files
dnfieldtvolkert
authored andcommitted
Use test_api instead of test (#120)
This will get rid of transitive dep on test package for flutter_tools. I also updated some deprecated member use and some various style stuff from Flutter's analysis options - I was going to do that for the file package as well but that's a bigger chore. If we'd rather have it all in one PR I can do that though.
1 parent 27049dd commit 14ba9ef

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

packages/file_testing/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#### 2.1.0
2+
3+
* Changed dependency on `package:test` to `package:test_api`
4+
* Bumped Dart SDK constraint to match `package:test_api`'s requirements
5+
* Updated style to match latest lint rules from Flutter repo.
6+
17
#### 2.0.3
28

39
* Relaxed constraints on `package:test`

packages/file_testing/lib/src/testing/core_matchers.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@
44

55
import 'dart:io';
66

7-
import 'package:test/test.dart';
7+
import 'package:test_api/test_api.dart';
88

99
import 'internal.dart';
1010

1111
/// Matcher that successfully matches against any instance of [Directory].
12-
const Matcher isDirectory = const isInstanceOf<Directory>();
12+
const Matcher isDirectory = TypeMatcher<Directory>();
1313

1414
/// Matcher that successfully matches against any instance of [File].
15-
const Matcher isFile = const isInstanceOf<File>();
15+
const Matcher isFile = TypeMatcher<File>();
1616

1717
/// Matcher that successfully matches against any instance of [Link].
18-
const Matcher isLink = const isInstanceOf<Link>();
18+
const Matcher isLink = TypeMatcher<Link>();
1919

2020
/// Matcher that successfully matches against any instance of
2121
/// [FileSystemEntity].
22-
const Matcher isFileSystemEntity = const isInstanceOf<FileSystemEntity>();
22+
const Matcher isFileSystemEntity = TypeMatcher<FileSystemEntity>();
2323

2424
/// Matcher that successfully matches against any instance of [FileStat].
25-
const Matcher isFileStat = const isInstanceOf<FileStat>();
25+
const Matcher isFileStat = TypeMatcher<FileStat>();
2626

2727
/// Returns a [Matcher] that matches [path] against an entity's path.
2828
///
2929
/// [path] may be a String, a predicate function, or a [Matcher]. If it is
3030
/// a String, it will be wrapped in an equality matcher.
31-
Matcher hasPath(dynamic path) => new _HasPath(path);
31+
Matcher hasPath(dynamic path) => _HasPath(path);
3232

3333
/// Returns a [Matcher] that successfully matches against an instance of
3434
/// [FileSystemException].
@@ -39,7 +39,7 @@ Matcher hasPath(dynamic path) => new _HasPath(path);
3939
/// [osErrorCode] may be an `int`, a predicate function, or a [Matcher]. If it
4040
/// is an `int`, it will be wrapped in an equality matcher.
4141
Matcher isFileSystemException([dynamic osErrorCode]) =>
42-
new _FileSystemException(osErrorCode);
42+
_FileSystemException(osErrorCode);
4343

4444
/// Returns a matcher that successfully matches against a future or function
4545
/// that throws a [FileSystemException].
@@ -67,14 +67,14 @@ void expectFileSystemException(dynamic osErrorCode, void callback()) {
6767

6868
/// Matcher that successfully matches against a [FileSystemEntity] that
6969
/// exists ([FileSystemEntity.existsSync] returns true).
70-
const Matcher exists = const _Exists();
70+
const Matcher exists = _Exists();
7171

7272
class _FileSystemException extends Matcher {
73-
final Matcher _matcher;
74-
7573
_FileSystemException(dynamic osErrorCode)
7674
: _matcher = _wrapMatcher(osErrorCode);
7775

76+
final Matcher _matcher;
77+
7878
static Matcher _wrapMatcher(dynamic osErrorCode) {
7979
if (osErrorCode == null) {
8080
return null;
@@ -85,8 +85,8 @@ class _FileSystemException extends Matcher {
8585
@override
8686
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
8787
if (item is FileSystemException) {
88-
return (_matcher == null ||
89-
_matcher.matches(item.osError?.errorCode, matchState));
88+
return _matcher == null ||
89+
_matcher.matches(item.osError?.errorCode, matchState);
9090
}
9191
return false;
9292
}
@@ -103,10 +103,10 @@ class _FileSystemException extends Matcher {
103103
}
104104

105105
class _HasPath extends Matcher {
106-
final Matcher _matcher;
107-
108106
_HasPath(dynamic path) : _matcher = wrapMatcher(path);
109107

108+
final Matcher _matcher;
109+
110110
@override
111111
bool matches(dynamic item, Map<dynamic, dynamic> matchState) =>
112112
_matcher.matches(item.path, matchState);
@@ -125,7 +125,7 @@ class _HasPath extends Matcher {
125125
bool verbose,
126126
) {
127127
desc.add('has path: \'${item.path}\'').add('\n Which: ');
128-
Description pathDesc = new StringDescription();
128+
final Description pathDesc = StringDescription();
129129
_matcher.describeMismatch(item.path, pathDesc, matchState, verbose);
130130
desc.add(pathDesc.toString());
131131
return desc;

packages/file_testing/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: file_testing
2-
version: 2.0.3
2+
version: 2.1.0
33
authors:
44
- Todd Volkert <[email protected]>
55
description: Testing utilities for package:file
66
homepage: https://github.com/google/file.dart/packages/file_testing
77

88
dependencies:
99
meta: ^1.1.2
10-
test: '>=1.0.0 <2.0.0'
10+
test_api: ^0.2.2
1111

1212
environment:
13-
sdk: '>=2.0.0-dev.28.0 <3.0.0'
13+
sdk: '>=2.1.0 <3.0.0'

0 commit comments

Comments
 (0)