OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /// Test infrastructure for testing pub. | 5 /// Test infrastructure for testing pub. |
6 /// | 6 /// |
7 /// Unlike typical unit tests, most pub tests are integration tests that stage | 7 /// Unlike typical unit tests, most pub tests are integration tests that stage |
8 /// some stuff on the file system, run pub, and then validate the results. This | 8 /// some stuff on the file system, run pub, and then validate the results. This |
9 /// library provides an API to build tests like that. | 9 /// library provides an API to build tests like that. |
10 library test_pub; | 10 library test_pub; |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 } | 828 } |
829 | 829 |
830 return lockFile; | 830 return lockFile; |
831 } | 831 } |
832 | 832 |
833 /// Uses [client] as the mock HTTP client for this test. | 833 /// Uses [client] as the mock HTTP client for this test. |
834 /// | 834 /// |
835 /// Note that this will only affect HTTP requests made via http.dart in the | 835 /// Note that this will only affect HTTP requests made via http.dart in the |
836 /// parent process. | 836 /// parent process. |
837 void useMockClient(MockClient client) { | 837 void useMockClient(MockClient client) { |
838 var oldInnerClient = httpClient.inner; | 838 var oldInnerClient = innerHttpClient; |
839 httpClient.inner = client; | 839 innerHttpClient = client; |
840 currentSchedule.onComplete.schedule(() { | 840 currentSchedule.onComplete.schedule(() { |
841 httpClient.inner = oldInnerClient; | 841 innerHttpClient = oldInnerClient; |
842 }, 'de-activating the mock client'); | 842 }, 'de-activating the mock client'); |
843 } | 843 } |
844 | 844 |
845 /// Describes a map representing a library package with the given [name], | 845 /// Describes a map representing a library package with the given [name], |
846 /// [version], and [dependencies]. | 846 /// [version], and [dependencies]. |
847 Map packageMap(String name, String version, [Map dependencies]) { | 847 Map packageMap(String name, String version, [Map dependencies]) { |
848 var package = { | 848 var package = { |
849 "name": name, | 849 "name": name, |
850 "version": version, | 850 "version": version, |
851 "author": "Nathan Weizenbaum <nweiz@google.com>", | 851 "author": "Nathan Weizenbaum <nweiz@google.com>", |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 _lastMatcher.matches(item.last, matchState); | 1012 _lastMatcher.matches(item.last, matchState); |
1013 } | 1013 } |
1014 | 1014 |
1015 Description describe(Description description) { | 1015 Description describe(Description description) { |
1016 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 1016 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
1017 } | 1017 } |
1018 } | 1018 } |
1019 | 1019 |
1020 /// A [StreamMatcher] that matches multiple lines of output. | 1020 /// A [StreamMatcher] that matches multiple lines of output. |
1021 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); | 1021 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); |
OLD | NEW |