Skip to content

Commit

Permalink
Update tests to latest package:checks (#55)
Browse files Browse the repository at this point in the history
Handle rename from `checkThat` to `check`.
  • Loading branch information
natebosch authored Feb 7, 2023
1 parent 0cdac2f commit aaf485c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion pkgs/corpus/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies:
yaml: ^3.0.0

dev_dependencies:
checks: ^0.1.0
checks: ^0.2.0
dart_flutter_team_lints: ^0.1.0
test: ^1.22.0
test_descriptor: ^2.0.0
18 changes: 9 additions & 9 deletions pkgs/corpus/test/api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ void main() {
var tempFile = File(path.join(sandbox, 'temp.json'));
sampleUsage.toFile(tempFile);

checkThat(tempFile.existsSync()).isTrue();
check(tempFile.existsSync()).isTrue();

// we have a reference to the main package entry-point
checkThat(tempFile.readAsStringSync()).contains('package:path/path.dart');
check(tempFile.readAsStringSync()).contains('package:path/path.dart');
});

test('fromFile', () {
Expand All @@ -47,33 +47,33 @@ void main() {
tempFile,
);

checkThat(result).isNotNull();
check(result).isNotNull();

var fromPackages = result.fromPackages;

// we have a library reference from package:build
checkThat(
check(
fromPackages.getLibraryReferences('package:path/path.dart'),
).contains(PackageEntity('build'));

// there are no references to classes
checkThat(fromPackages.sortedClassReferences).isEmpty();
check(fromPackages.sortedClassReferences).isEmpty();

// there are references to top-level symbols
checkThat(fromPackages.sortedTopLevelReferences).isNotEmpty();
check(fromPackages.sortedTopLevelReferences).isNotEmpty();

var fromLibraries = result.fromLibraries;

// we have a library reference from package:build
checkThat(
check(
fromLibraries.getLibraryReferences('package:path/path.dart'),
).isNotEmpty();

// there are no references to classes
checkThat(fromLibraries.sortedClassReferences).isEmpty();
check(fromLibraries.sortedClassReferences).isEmpty();

// there are references to top-level symbols
checkThat(fromLibraries.sortedTopLevelReferences).isNotEmpty();
check(fromLibraries.sortedTopLevelReferences).isNotEmpty();
});
});
}
Expand Down
12 changes: 6 additions & 6 deletions pkgs/corpus/test/pub_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ void main() {
var packageInfo =
PackageInfo.from(jsonDecode(_pubSampleData) as Map<String, dynamic>);

checkThat(packageInfo.name).equals('usage');
checkThat(packageInfo.version).equals('4.0.2');
checkThat(packageInfo.archiveUrl).isNotNull();
checkThat(packageInfo.publishedDate).isNotNull();
check(packageInfo.name).equals('usage');
check(packageInfo.version).equals('4.0.2');
check(packageInfo.archiveUrl).isNotNull();
check(packageInfo.publishedDate).isNotNull();

checkThat(packageInfo.constraintFor('path')).isNotNull().allows('1.8.0');
checkThat(packageInfo.constraintFor('test')).isNotNull().allows('1.16.0');
check(packageInfo.constraintFor('path')).isNotNull().allows('1.8.0');
check(packageInfo.constraintFor('test')).isNotNull().allows('1.16.0');
});
});
}
Expand Down
48 changes: 24 additions & 24 deletions pkgs/corpus/test/visitor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ void main() {

await surveyor.analyze();

checkThat(apiUsageCollector.referringPackages.sortedLibraryReferences)
check(apiUsageCollector.referringPackages.sortedLibraryReferences)
.containsKey('package:path/path.dart');
checkThat(apiUsageCollector.referringLibraries.sortedLibraryReferences)
check(apiUsageCollector.referringLibraries.sortedLibraryReferences)
.containsKey('package:path/path.dart');
});

Expand All @@ -57,15 +57,15 @@ void main() {
await surveyor.analyze();

// class constructor invocation
checkThat(apiUsageCollector.referringPackages.sortedClassReferences)
check(apiUsageCollector.referringPackages.sortedClassReferences)
.containsKey('PosixStyle');
checkThat(apiUsageCollector.referringLibraries.sortedClassReferences)
check(apiUsageCollector.referringLibraries.sortedClassReferences)
.containsKey('PosixStyle');

// class static variable reference
checkThat(apiUsageCollector.referringPackages.sortedClassReferences)
check(apiUsageCollector.referringPackages.sortedClassReferences)
.containsKey('Style');
checkThat(apiUsageCollector.referringLibraries.sortedClassReferences)
check(apiUsageCollector.referringLibraries.sortedClassReferences)
.containsKey('Style');
});

Expand All @@ -89,9 +89,9 @@ void main() {

await surveyor.analyze();

checkThat(apiUsageCollector.referringPackages.sortedExtensionReferences)
check(apiUsageCollector.referringPackages.sortedExtensionReferences)
.containsKey('IterableExtension');
checkThat(apiUsageCollector.referringLibraries.sortedExtensionReferences)
check(apiUsageCollector.referringLibraries.sortedExtensionReferences)
.containsKey('IterableExtension');
});

Expand All @@ -104,15 +104,15 @@ void main() {
await surveyor.analyze();

// check for a top level function invokation
checkThat(apiUsageCollector.referringPackages.sortedTopLevelReferences)
check(apiUsageCollector.referringPackages.sortedTopLevelReferences)
.containsKey('join');
checkThat(apiUsageCollector.referringLibraries.sortedTopLevelReferences)
check(apiUsageCollector.referringLibraries.sortedTopLevelReferences)
.containsKey('join');

// check for a top level getter reference
checkThat(apiUsageCollector.referringPackages.sortedTopLevelReferences)
check(apiUsageCollector.referringPackages.sortedTopLevelReferences)
.containsKey('basename');
checkThat(apiUsageCollector.referringLibraries.sortedTopLevelReferences)
check(apiUsageCollector.referringLibraries.sortedTopLevelReferences)
.containsKey('basename');
});
});
Expand Down Expand Up @@ -143,9 +143,9 @@ void main() {

await surveyor.analyze();

checkThat(apiUsageCollector.referringPackages.sortedLibraryReferences)
check(apiUsageCollector.referringPackages.sortedLibraryReferences)
.containsKey('dart:collection');
checkThat(apiUsageCollector.referringLibraries.sortedLibraryReferences)
check(apiUsageCollector.referringLibraries.sortedLibraryReferences)
.containsKey('dart:collection');
});

Expand All @@ -158,15 +158,15 @@ void main() {
await surveyor.analyze();

// class constructor invocation
checkThat(apiUsageCollector.referringPackages.sortedClassReferences)
check(apiUsageCollector.referringPackages.sortedClassReferences)
.containsKey('SplayTreeMap');
checkThat(apiUsageCollector.referringLibraries.sortedClassReferences)
check(apiUsageCollector.referringLibraries.sortedClassReferences)
.containsKey('SplayTreeMap');

// class static method reference
checkThat(apiUsageCollector.referringPackages.sortedClassReferences)
check(apiUsageCollector.referringPackages.sortedClassReferences)
.containsKey('Queue');
checkThat(apiUsageCollector.referringLibraries.sortedClassReferences)
check(apiUsageCollector.referringLibraries.sortedClassReferences)
.containsKey('Queue');
});

Expand All @@ -187,15 +187,15 @@ void main() {
await surveyor.analyze();

// check for a top level function invokation
checkThat(apiUsageCollector.referringPackages.sortedTopLevelReferences)
check(apiUsageCollector.referringPackages.sortedTopLevelReferences)
.containsKey('jsonDecode');
checkThat(apiUsageCollector.referringLibraries.sortedTopLevelReferences)
check(apiUsageCollector.referringLibraries.sortedTopLevelReferences)
.containsKey('jsonDecode');

// check for a top level getter reference
checkThat(apiUsageCollector.referringPackages.sortedTopLevelReferences)
check(apiUsageCollector.referringPackages.sortedTopLevelReferences)
.containsKey('base64');
checkThat(apiUsageCollector.referringLibraries.sortedTopLevelReferences)
check(apiUsageCollector.referringLibraries.sortedTopLevelReferences)
.containsKey('base64');
});

Expand All @@ -213,9 +213,9 @@ void main() {

await surveyor.analyze();

checkThat(apiUsageCollector.referringPackages.sortedExtensionReferences)
check(apiUsageCollector.referringPackages.sortedExtensionReferences)
.containsKey('FutureExtensions');
checkThat(apiUsageCollector.referringLibraries.sortedExtensionReferences)
check(apiUsageCollector.referringLibraries.sortedExtensionReferences)
.containsKey('FutureExtensions');
});
});
Expand Down

0 comments on commit aaf485c

Please sign in to comment.