Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(966)

Side by Side Diff: sdk/lib/_internal/pub/test/lock_file_test.dart

Issue 14681002: Sort pubspec.lock packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed print statement. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/lock_file.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library lock_file_test; 5 library lock_file_test;
6 6
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'package:yaml/yaml.dart'; 8 import 'package:yaml/yaml.dart';
9 9
10 import '../lib/src/lock_file.dart'; 10 import '../lib/src/lock_file.dart';
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 foo: 152 foo:
153 bonus: not used 153 bonus: not used
154 version: 1.2.3 154 version: 1.2.3
155 source: mock 155 source: mock
156 description: foo desc 156 description: foo desc
157 ''', sources); 157 ''', sources);
158 }); 158 });
159 }); 159 });
160 160
161 group('serialize()', () { 161 group('serialize()', () {
162 var lockfile;
163 setUp(() {
164 lockfile = new LockFile.empty();
165 });
166
162 test('dumps the lockfile to YAML', () { 167 test('dumps the lockfile to YAML', () {
163 var lockfile = new LockFile.empty();
164 lockfile.packages['foo'] = new PackageId( 168 lockfile.packages['foo'] = new PackageId(
165 'foo', mockSource, new Version.parse('1.2.3'), 'foo desc'); 169 'foo', mockSource, new Version.parse('1.2.3'), 'foo desc');
166 lockfile.packages['bar'] = new PackageId( 170 lockfile.packages['bar'] = new PackageId(
167 'foo', mockSource, new Version.parse('3.2.1'), 'bar desc'); 171 'bar', mockSource, new Version.parse('3.2.1'), 'bar desc');
168 172
169 expect(loadYaml(lockfile.serialize()), equals({ 173 expect(loadYaml(lockfile.serialize()), equals({
170 'packages': { 174 'packages': {
171 'foo': { 175 'foo': {
172 'version': '1.2.3', 176 'version': '1.2.3',
173 'source': 'mock', 177 'source': 'mock',
174 'description': 'foo desc' 178 'description': 'foo desc'
175 }, 179 },
176 'bar': { 180 'bar': {
177 'version': '3.2.1', 181 'version': '3.2.1',
178 'source': 'mock', 182 'source': 'mock',
179 'description': 'bar desc' 183 'description': 'bar desc'
180 } 184 }
181 } 185 }
182 })); 186 }));
183 }); 187 });
188
189 test('lockfile is alphabetized by package name', () {
190 var testNames = ['baz', 'Qwe', 'Q', 'B', 'Bar', 'bar', 'foo'];
191 testNames.forEach((name) {
192 lockfile.packages[name] = new PackageId(name, mockSource,
193 new Version.parse('5.5.5'), '$name desc');
194 });
195
196 expect(lockfile.serialize(),
197 '# Generated by pub\n'
198 '# See http://pub.dartlang.org/doc/glossary.html#lockfile\n'
199 '\n'
200 '{"packages":{'
201 '"B":{"version":"5.5.5","source":"mock","description":"B desc"},'
202 '"Bar":{"version":"5.5.5","source":"mock","description":"Bar desc"},'
203 '"Q":{"version":"5.5.5","source":"mock","description":"Q desc"},'
204 '"Qwe":{"version":"5.5.5","source":"mock","description":"Qwe desc"},'
205 '"bar":{"version":"5.5.5","source":"mock","description":"bar desc"},'
206 '"baz":{"version":"5.5.5","source":"mock","description":"baz desc"},'
207 '"foo":{"version":"5.5.5","source":"mock","description":"foo desc"}}}'
208 '\n'
209 );
210 });
184 }); 211 });
185 }); 212 });
186 } 213 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/lock_file.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698