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

Side by Side Diff: test/descriptor.dart

Issue 1664903003: Properly include the hosted URL in all IDs. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « lib/src/source/hosted.dart ('k') | test/get/hosted/get_test.dart » ('j') | 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) 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 /// Pub-specific scheduled_test descriptors. 5 /// Pub-specific scheduled_test descriptors.
6 import 'package:oauth2/oauth2.dart' as oauth2; 6 import 'package:oauth2/oauth2.dart' as oauth2;
7 import 'package:pub/src/io.dart'; 7 import 'package:pub/src/io.dart';
8 import 'package:pub/src/utils.dart'; 8 import 'package:pub/src/utils.dart';
9 import 'package:scheduled_test/descriptor.dart'; 9 import 'package:scheduled_test/descriptor.dart';
10 import 'package:scheduled_test/scheduled_server.dart'; 10 import 'package:scheduled_test/scheduled_server.dart';
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 return dir(packagesPath, contents); 120 return dir(packagesPath, contents);
121 } 121 }
122 122
123 /// Describes the global package cache directory containing all the given 123 /// Describes the global package cache directory containing all the given
124 /// [packages], which should be name/version pairs. The packages will be 124 /// [packages], which should be name/version pairs. The packages will be
125 /// validated against the format produced by the mock package server. 125 /// validated against the format produced by the mock package server.
126 /// 126 ///
127 /// A package's value may also be a list of versions, in which case all 127 /// A package's value may also be a list of versions, in which case all
128 /// versions are expected to be downloaded. 128 /// versions are expected to be downloaded.
129 /// 129 ///
130 /// If [port] is passed, it's used as the port number of the local hosted server
131 /// that this cache represents. It may be either an `int` or a `Future<int>`.
132 ///
130 /// If [includePubspecs] is `true`, then pubspecs will be created for each 133 /// If [includePubspecs] is `true`, then pubspecs will be created for each
131 /// package. Defaults to `false` so that the contents of pubspecs are not 134 /// package. Defaults to `false` so that the contents of pubspecs are not
132 /// validated since they will often lack the dependencies section that the 135 /// validated since they will often lack the dependencies section that the
133 /// real pubspec being compared against has. You usually only need to pass 136 /// real pubspec being compared against has. You usually only need to pass
134 /// `true` for this if you plan to call [create] on the resulting descriptor. 137 /// `true` for this if you plan to call [create] on the resulting descriptor.
135 Descriptor cacheDir(Map packages, {bool includePubspecs: false}) { 138 Descriptor cacheDir(Map packages, {port, bool includePubspecs: false}) {
136 var contents = <Descriptor>[]; 139 var contents = <Descriptor>[];
137 packages.forEach((name, versions) { 140 packages.forEach((name, versions) {
138 if (versions is! List) versions = [versions]; 141 if (versions is! List) versions = [versions];
139 for (var version in versions) { 142 for (var version in versions) {
140 var packageContents = [libDir(name, '$name $version')]; 143 var packageContents = [libDir(name, '$name $version')];
141 if (includePubspecs) { 144 if (includePubspecs) {
142 packageContents.add(libPubspec(name, version)); 145 packageContents.add(libPubspec(name, version));
143 } 146 }
144 contents.add(dir("$name-$version", packageContents)); 147 contents.add(dir("$name-$version", packageContents));
145 } 148 }
146 }); 149 });
147 150
148 return hostedCache(contents); 151 return hostedCache(contents, port: port);
149 } 152 }
150 153
151 /// Describes the main cache directory containing cached hosted packages 154 /// Describes the main cache directory containing cached hosted packages
152 /// downloaded from the mock package server. 155 /// downloaded from the mock package server.
153 Descriptor hostedCache(Iterable<Descriptor> contents) { 156 ///
157 /// If [port] is passed, it's used as the port number of the local hosted server
158 /// that this cache represents. It may be either an `int` or a `Future<int>`.
159 Descriptor hostedCache(Iterable<Descriptor> contents, {port}) {
154 return dir(cachePath, [ 160 return dir(cachePath, [
155 dir('hosted', [ 161 dir('hosted', [
156 async(globalServer.port.then((p) => dir('localhost%58$p', contents))) 162 async(awaitObject(port ?? globalServer.port)
163 .then((p) => dir('localhost%58$p', contents)))
157 ]) 164 ])
158 ]); 165 ]);
159 } 166 }
160 167
161 /// Describes the file in the system cache that contains the client's OAuth2 168 /// Describes the file in the system cache that contains the client's OAuth2
162 /// credentials. The URL "/token" on [server] will be used as the token 169 /// credentials. The URL "/token" on [server] will be used as the token
163 /// endpoint for refreshing the access token. 170 /// endpoint for refreshing the access token.
164 Descriptor credentialsFile( 171 Descriptor credentialsFile(
165 ScheduledServer server, 172 ScheduledServer server,
166 String accessToken, 173 String accessToken,
(...skipping 22 matching lines...) Expand all
189 /// are located on disk. If the strings are semantic versions, then the packages 196 /// are located on disk. If the strings are semantic versions, then the packages
190 /// are located in the system cache; otherwise, the strings are interpreted as 197 /// are located in the system cache; otherwise, the strings are interpreted as
191 /// relative `file:` URLs. 198 /// relative `file:` URLs.
192 /// 199 ///
193 /// Validation checks that the `.packages` file exists, has the expected 200 /// Validation checks that the `.packages` file exists, has the expected
194 /// entries (one per key in [dependencies]), each with a path that contains 201 /// entries (one per key in [dependencies]), each with a path that contains
195 /// either the version string (for a reference to the pub cache) or a 202 /// either the version string (for a reference to the pub cache) or a
196 /// path to a path dependency, relative to the application directory. 203 /// path to a path dependency, relative to the application directory.
197 Descriptor packagesFile([Map dependencies]) => 204 Descriptor packagesFile([Map dependencies]) =>
198 new PackagesFileDescriptor(dependencies); 205 new PackagesFileDescriptor(dependencies);
OLDNEW
« no previous file with comments | « lib/src/source/hosted.dart ('k') | test/get/hosted/get_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698