Skip to content

Commit

Permalink
Connect to _PUB_TEST_DEFAULT_HOSTED_URL instead of pub.dev when testi…
Browse files Browse the repository at this point in the history
…ng (#4270)
  • Loading branch information
sigurdm committed May 16, 2024
1 parent c2592b3 commit 7ab4020
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 154 deletions.
5 changes: 5 additions & 0 deletions lib/src/source/hosted.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ Uri validateAndNormalizeHostedUrl(String hostedUrl) {
log.fine('Using https://pub.dev instead of https://pub.dartlang.org.');
u = Uri.parse('https://pub.dev');
}
if (runningFromTest &&
u == Uri.parse('https://pub.dev') &&
Platform.environment.containsKey('_PUB_TEST_DEFAULT_HOSTED_URL')) {
u = Uri.parse(Platform.environment['_PUB_TEST_DEFAULT_HOSTED_URL']!);
}
return u;
}

Expand Down
4 changes: 2 additions & 2 deletions test/dependency_services/dependency_services_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ Future<void> main() async {

testWithGolden('Preserves pub.dartlang.org as hosted url', (context) async {
final server = (await servePackages())
..serve('foo', '1.2.3')
..serve('bar', '1.2.3')
..serve(r'foo', '1.2.3')
..serve(r'bar', '1.2.3')
..serveContentHashes = true;

await d.dir(appPath, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ $ echo '' | dependency_services list
"type": "hosted",
"description": {
"name": "bar",
"url": "https://pub.dev",
"url": "http://localhost:$PORT",
"sha256": "0b119406be305b6e65d33551008b5b72fdd810965f0df914478c940d5fe28e53"
}
}
Expand All @@ -53,7 +53,7 @@ $ echo '' | dependency_services list
"type": "hosted",
"description": {
"name": "foo",
"url": "https://pub.dev",
"url": "http://localhost:$PORT",
"sha256": "b2b7fc405959806aa1f31ac7e68752534f66f66a11a280d9878ecb6cd835f01c"
}
}
Expand All @@ -75,121 +75,15 @@ $ echo '' | dependency_services report
"type": "hosted",
"description": {
"name": "bar",
"url": "https://pub.dev",
"url": "http://localhost:$PORT",
"sha256": "0b119406be305b6e65d33551008b5b72fdd810965f0df914478c940d5fe28e53"
}
},
"latest": null,
"latest": "1.2.3",
"constraint": "^1.0.0",
"compatible": [
{
"name": "bar",
"version": "1.2.3",
"kind": "direct",
"source": {
"type": "hosted",
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
"sha256": "0b119406be305b6e65d33551008b5b72fdd810965f0df914478c940d5fe28e53"
}
},
"constraintBumped": "^1.0.0",
"constraintWidened": "^1.0.0",
"constraintBumpedIfNeeded": "^1.0.0",
"previousVersion": "1.2.3",
"previousConstraint": "^1.0.0",
"previousSource": {
"type": "hosted",
"description": {
"name": "bar",
"url": "https://pub.dev",
"sha256": "0b119406be305b6e65d33551008b5b72fdd810965f0df914478c940d5fe28e53"
}
}
},
{
"name": "foo",
"version": "1.2.4",
"kind": "direct",
"source": {
"type": "hosted",
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
"sha256": "0362935f659b1fd166b6036575bffd6e735cd9953eb60324192d1fdd4929b4c1"
}
},
"constraintBumped": "^1.0.0",
"constraintWidened": "^1.0.0",
"constraintBumpedIfNeeded": "^1.0.0",
"previousVersion": "1.2.3",
"previousConstraint": "^1.0.0",
"previousSource": {
"type": "hosted",
"description": {
"name": "foo",
"url": "https://pub.dev",
"sha256": "b2b7fc405959806aa1f31ac7e68752534f66f66a11a280d9878ecb6cd835f01c"
}
}
}
],
"compatible": [],
"singleBreaking": [],
"multiBreaking": [
{
"name": "bar",
"version": "1.2.3",
"kind": "direct",
"source": {
"type": "hosted",
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
"sha256": "0b119406be305b6e65d33551008b5b72fdd810965f0df914478c940d5fe28e53"
}
},
"constraintBumped": "^1.2.3",
"constraintWidened": "^1.0.0",
"constraintBumpedIfNeeded": "^1.0.0",
"previousVersion": "1.2.3",
"previousConstraint": "^1.0.0",
"previousSource": {
"type": "hosted",
"description": {
"name": "bar",
"url": "https://pub.dev",
"sha256": "0b119406be305b6e65d33551008b5b72fdd810965f0df914478c940d5fe28e53"
}
}
},
{
"name": "foo",
"version": "1.2.4",
"kind": "direct",
"source": {
"type": "hosted",
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
"sha256": "0362935f659b1fd166b6036575bffd6e735cd9953eb60324192d1fdd4929b4c1"
}
},
"constraintBumped": "^1.2.4",
"constraintWidened": "^1.0.0",
"constraintBumpedIfNeeded": "^1.0.0",
"previousVersion": "1.2.3",
"previousConstraint": "^1.0.0",
"previousSource": {
"type": "hosted",
"description": {
"name": "foo",
"url": "https://pub.dev",
"sha256": "b2b7fc405959806aa1f31ac7e68752534f66f66a11a280d9878ecb6cd835f01c"
}
}
}
]
"multiBreaking": []
},
{
"name": "foo",
Expand All @@ -199,23 +93,23 @@ $ echo '' | dependency_services report
"type": "hosted",
"description": {
"name": "foo",
"url": "https://pub.dev",
"url": "http://localhost:$PORT",
"sha256": "b2b7fc405959806aa1f31ac7e68752534f66f66a11a280d9878ecb6cd835f01c"
}
},
"latest": "0.0.1",
"latest": "1.2.4",
"constraint": "^1.0.0",
"compatible": [
{
"name": "bar",
"version": "1.2.3",
"name": "foo",
"version": "1.2.4",
"kind": "direct",
"source": {
"type": "hosted",
"description": {
"name": "bar",
"name": "foo",
"url": "http://localhost:$PORT",
"sha256": "0b119406be305b6e65d33551008b5b72fdd810965f0df914478c940d5fe28e53"
"sha256": "0362935f659b1fd166b6036575bffd6e735cd9953eb60324192d1fdd4929b4c1"
}
},
"constraintBumped": "^1.0.0",
Expand All @@ -226,12 +120,14 @@ $ echo '' | dependency_services report
"previousSource": {
"type": "hosted",
"description": {
"name": "bar",
"url": "https://pub.dev",
"sha256": "0b119406be305b6e65d33551008b5b72fdd810965f0df914478c940d5fe28e53"
"name": "foo",
"url": "http://localhost:$PORT",
"sha256": "b2b7fc405959806aa1f31ac7e68752534f66f66a11a280d9878ecb6cd835f01c"
}
}
},
}
],
"singleBreaking": [
{
"name": "foo",
"version": "1.2.4",
Expand All @@ -244,7 +140,7 @@ $ echo '' | dependency_services report
"sha256": "0362935f659b1fd166b6036575bffd6e735cd9953eb60324192d1fdd4929b4c1"
}
},
"constraintBumped": "^1.0.0",
"constraintBumped": "^1.2.4",
"constraintWidened": "^1.0.0",
"constraintBumpedIfNeeded": "^1.0.0",
"previousVersion": "1.2.3",
Expand All @@ -253,40 +149,13 @@ $ echo '' | dependency_services report
"type": "hosted",
"description": {
"name": "foo",
"url": "https://pub.dev",
"url": "http://localhost:$PORT",
"sha256": "b2b7fc405959806aa1f31ac7e68752534f66f66a11a280d9878ecb6cd835f01c"
}
}
}
],
"singleBreaking": [],
"multiBreaking": [
{
"name": "bar",
"version": "1.2.3",
"kind": "direct",
"source": {
"type": "hosted",
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
"sha256": "0b119406be305b6e65d33551008b5b72fdd810965f0df914478c940d5fe28e53"
}
},
"constraintBumped": "^1.2.3",
"constraintWidened": "^1.0.0",
"constraintBumpedIfNeeded": "^1.0.0",
"previousVersion": "1.2.3",
"previousConstraint": "^1.0.0",
"previousSource": {
"type": "hosted",
"description": {
"name": "bar",
"url": "https://pub.dev",
"sha256": "0b119406be305b6e65d33551008b5b72fdd810965f0df914478c940d5fe28e53"
}
}
},
{
"name": "foo",
"version": "1.2.4",
Expand All @@ -308,7 +177,7 @@ $ echo '' | dependency_services report
"type": "hosted",
"description": {
"name": "foo",
"url": "https://pub.dev",
"url": "http://localhost:$PORT",
"sha256": "b2b7fc405959806aa1f31ac7e68752534f66f66a11a280d9878ecb6cd835f01c"
}
}
Expand Down

0 comments on commit 7ab4020

Please sign in to comment.