Merge pull request #19 from dart-lang/devoncarew_tests
put more code under test
diff --git a/lib/src/impl.dart b/lib/src/impl.dart
index 9a8c2a0..3a23de1 100644
--- a/lib/src/impl.dart
+++ b/lib/src/impl.dart
@@ -44,11 +44,13 @@
_resolver = resolver;
}
+ /// The git url.
+ String get url => _description['url'];
+
/// The git commit.
String get resolvedRef => _description['resolved-ref'];
- /// The git url.
- String get url => _description['url'];
+ String toString() => '${name} ${version} (${url}, ${resolvedRef})';
}
class PathPackageRefImpl extends PackageRefImpl {
@@ -66,6 +68,8 @@
Directory dir = new Directory(path);
return dir.existsSync() ? new Package(dir, name, version) : null;
}
+
+ String toString() => '${name} ${version} (${path}, relative=${relative})';
}
/// A reference to a package in the pub cache (for instance, something in
@@ -84,6 +88,8 @@
if (index != -1) {
_version = new Version.parse(_name.substring(index + 1));
_name = _name.substring(0, index);
+ } else {
+ _version = Version.none;
}
}
@@ -115,11 +121,8 @@
File f = new File(path.join(directory.path, 'pubspec.yaml'));
if (f.existsSync()) {
Map pubspec = yaml.loadYaml(f.readAsStringSync());
- if (pubspec['version'] == null) {
- _version = Version.none;
- } else {
- _version = new Version.parse(pubspec['version']);
- }
+ _version = pubspec.containsKey('version')
+ ? new Version.parse(pubspec['version']) : Version.none;
}
}
@@ -130,4 +133,6 @@
String get resolvedRef => _resolvedRef;
Package resolve() => new Package(directory, name, version);
+
+ String toString() => '${name} ${version} (${resolvedRef})';
}
diff --git a/test/pub_cache_test.dart b/test/pub_cache_test.dart
index 4301d6f..aa6951b 100644
--- a/test/pub_cache_test.dart
+++ b/test/pub_cache_test.dart
@@ -143,14 +143,25 @@
expect(buf.toString(), isNotEmpty);
});
+ test('everything parses', () {
+ StringBuffer buf = new StringBuffer();
+ PubCache cache = new PubCache();
+ var packageRefs = cache.getPackageRefs();
+ packageRefs.forEach((ref) {
+ expect(ref.version, isNotNull);
+ buf.writeln('${ref}');
+ });
+ expect(buf.toString(), isNotEmpty);
+ });
+
test('list packages', () {
StringBuffer buf = new StringBuffer();
PubCache cache = new PubCache();
var packages = cache.getCachedPackages();
packages.forEach((pkg) {
- List versions = cache.getAllPackageVersions(pkg);
+ List<PackageRef> versions = cache.getAllPackageVersions(pkg);
buf.writeln(
- ' ${pkg} [${versions.map((p) => p.version.toString()).join(', ')}]');
+ '${pkg} [${versions.map((p) => p.version.toString()).join(', ')}]');
});
expect(buf.toString(), isNotEmpty);
});
diff --git a/tool/travis.sh b/tool/travis.sh
index dc1d87b..9c9c989 100755
--- a/tool/travis.sh
+++ b/tool/travis.sh
@@ -9,6 +9,8 @@
# Activate some packages for use while running tests.
pub global activate dart_coveralls
+pub global activate path 1.3.0
+pub global activate path
pub global activate --source git https://github.com/dart-lang/test.git
pub global activate --source path .