OLD | NEW |
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('../../../lib/unittest/unittest.dart'); | 7 #import('../../../lib/unittest/unittest.dart'); |
8 #import('../../pub/lock_file.dart'); | 8 #import('../../pub/lock_file.dart'); |
9 #import('../../pub/package.dart'); | 9 #import('../../pub/package.dart'); |
10 #import('../../pub/source.dart'); | 10 #import('../../pub/source.dart'); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 expect(bar.description, equals('bar desc')); | 66 expect(bar.description, equals('bar desc')); |
67 | 67 |
68 var foo = lockFile.packages['foo']; | 68 var foo = lockFile.packages['foo']; |
69 expect(foo.name, equals('foo')); | 69 expect(foo.name, equals('foo')); |
70 expect(foo.version, equals(new Version(2, 3, 4))); | 70 expect(foo.version, equals(new Version(2, 3, 4))); |
71 expect(foo.source, equals(mockSource)); | 71 expect(foo.source, equals(mockSource)); |
72 expect(foo.description, equals('foo desc')); | 72 expect(foo.description, equals('foo desc')); |
73 }); | 73 }); |
74 | 74 |
75 test("throws if the version is missing", () { | 75 test("throws if the version is missing", () { |
76 throwsBadFormat(() { | 76 expect(() { |
77 new LockFile.parse(''' | 77 new LockFile.parse(''' |
78 packages: | 78 packages: |
79 foo: | 79 foo: |
80 source: mock | 80 source: mock |
81 description: foo desc | 81 description: foo desc |
82 ''', sources); | 82 ''', sources); |
83 }); | 83 }, throwsFormatException); |
84 }); | 84 }); |
85 | 85 |
86 test("throws if the version is invalid", () { | 86 test("throws if the version is invalid", () { |
87 throwsBadFormat(() { | 87 expect(() { |
88 new LockFile.parse(''' | 88 new LockFile.parse(''' |
89 packages: | 89 packages: |
90 foo: | 90 foo: |
91 version: vorpal | 91 version: vorpal |
92 source: mock | 92 source: mock |
93 description: foo desc | 93 description: foo desc |
94 ''', sources); | 94 ''', sources); |
95 }); | 95 }, throwsFormatException); |
96 }); | 96 }); |
97 | 97 |
98 test("throws if the source is missing", () { | 98 test("throws if the source is missing", () { |
99 throwsBadFormat(() { | 99 expect(() { |
100 new LockFile.parse(''' | 100 new LockFile.parse(''' |
101 packages: | 101 packages: |
102 foo: | 102 foo: |
103 version: 1.2.3 | 103 version: 1.2.3 |
104 description: foo desc | 104 description: foo desc |
105 ''', sources); | 105 ''', sources); |
106 }); | 106 }, throwsFormatException); |
107 }); | 107 }); |
108 | 108 |
109 test("throws if the source is unknown", () { | 109 test("throws if the source is unknown", () { |
110 throwsBadFormat(() { | 110 expect(() { |
111 new LockFile.parse(''' | 111 new LockFile.parse(''' |
112 packages: | 112 packages: |
113 foo: | 113 foo: |
114 version: 1.2.3 | 114 version: 1.2.3 |
115 source: notreal | 115 source: notreal |
116 description: foo desc | 116 description: foo desc |
117 ''', sources); | 117 ''', sources); |
118 }); | 118 }, throwsFormatException); |
119 }); | 119 }); |
120 | 120 |
121 test("throws if the description is missing", () { | 121 test("throws if the description is missing", () { |
122 throwsBadFormat(() { | 122 expect(() { |
123 new LockFile.parse(''' | 123 new LockFile.parse(''' |
124 packages: | 124 packages: |
125 foo: | 125 foo: |
126 version: 1.2.3 | 126 version: 1.2.3 |
127 source: mock | 127 source: mock |
128 ''', sources); | 128 ''', sources); |
129 }); | 129 }, throwsFormatException); |
130 }); | 130 }); |
131 | 131 |
132 test("throws if the description is invalid", () { | 132 test("throws if the description is invalid", () { |
133 throwsBadFormat(() { | 133 expect(() { |
134 new LockFile.parse(''' | 134 new LockFile.parse(''' |
135 packages: | 135 packages: |
136 foo: | 136 foo: |
137 version: 1.2.3 | 137 version: 1.2.3 |
138 source: mock | 138 source: mock |
139 description: foo desc is bad | 139 description: foo desc is bad |
140 ''', sources); | 140 ''', sources); |
141 }); | 141 }, throwsFormatException); |
142 }); | 142 }); |
143 | 143 |
144 test("throws if the source name doesn't match the given name", () { | 144 test("throws if the source name doesn't match the given name", () { |
145 throwsBadFormat(() { | 145 expect(() { |
146 new LockFile.parse(''' | 146 new LockFile.parse(''' |
147 packages: | 147 packages: |
148 foo: | 148 foo: |
149 version: 1.2.3 | 149 version: 1.2.3 |
150 source: mock | 150 source: mock |
151 description: notfoo desc | 151 description: notfoo desc |
152 ''', sources); | 152 ''', sources); |
153 }); | 153 }, throwsFormatException); |
154 }); | 154 }); |
155 | 155 |
156 test("ignores extra stuff in file", () { | 156 test("ignores extra stuff in file", () { |
157 var lockFile = new LockFile.parse(''' | 157 var lockFile = new LockFile.parse(''' |
158 extra: | 158 extra: |
159 some: stuff | 159 some: stuff |
160 packages: | 160 packages: |
161 foo: | 161 foo: |
162 bonus: not used | 162 bonus: not used |
163 version: 1.2.3 | 163 version: 1.2.3 |
(...skipping 22 matching lines...) Expand all Loading... |
186 'version': '3.2.1', | 186 'version': '3.2.1', |
187 'source': 'mock', | 187 'source': 'mock', |
188 'description': 'bar desc' | 188 'description': 'bar desc' |
189 } | 189 } |
190 } | 190 } |
191 })); | 191 })); |
192 }); | 192 }); |
193 }); | 193 }); |
194 }); | 194 }); |
195 } | 195 } |
196 | |
197 throwsBadFormat(function) { | |
198 expect(function, throwsA((e) => e is FormatException)); | |
199 } | |
OLD | NEW |