Skip to content

Commit b2f643e

Browse files
committed
Test that runtimeSDKVersion is used in image proxy dockerfile
1 parent 6dc8d84 commit b2f643e

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

app/test/shared/versions_test.dart

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void main() {
6565
'accepted runtime versions should be lexicographically ordered',
6666
() {
6767
for (final version in acceptedRuntimeVersions) {
68-
expect(runtimeVersionPattern.hasMatch(version), isTrue);
68+
expect(version, matches(runtimeVersionPattern));
6969
}
7070
final sorted = [...acceptedRuntimeVersions]
7171
..sort((a, b) => -a.compareTo(b));
@@ -77,23 +77,29 @@ void main() {
7777
expect(acceptedRuntimeVersions, hasLength(lessThan(6)));
7878
});
7979

80-
test('runtime sdk version should match CI and dockerfile', () async {
80+
test('runtime sdk version should match CI and dockerfiles', () async {
8181
final String docker = await File('../Dockerfile.app').readAsString();
82-
expect(docker.contains('\nFROM dart:$runtimeSdkVersion\n'), isTrue);
82+
expect(docker, contains('\nFROM dart:$runtimeSdkVersion\n'));
8383
final ci = await File('../.github/workflows/all-test.yml').readAsString();
84-
expect(ci.contains("DART_SDK_VERSION: '$runtimeSdkVersion'"), isTrue);
84+
expect(ci, contains("DART_SDK_VERSION: '$runtimeSdkVersion'"));
85+
final imageProxyDocker = await File(
86+
'../pkg/image_proxy/Dockerfile',
87+
).readAsString();
88+
expect(imageProxyDocker, contains('\nFROM dart:$runtimeSdkVersion '));
8589
});
8690

8791
test('Dart SDK versions should match Dockerfile.worker', () async {
8892
final dockerfileContent = await File('../Dockerfile.worker').readAsString();
8993
expect(
90-
dockerfileContent.contains(
91-
'tool/setup-dart.sh /home/worker/dart/stable stable/raw/hash/',
92-
) ||
93-
dockerfileContent.contains(
94-
'tool/setup-dart.sh /home/worker/dart/stable $toolStableDartSdkVersion',
95-
),
96-
isTrue,
94+
dockerfileContent,
95+
anyOf(
96+
contains(
97+
'tool/setup-dart.sh /home/worker/dart/stable stable/raw/hash/',
98+
),
99+
contains(
100+
'tool/setup-dart.sh /home/worker/dart/stable $toolStableDartSdkVersion',
101+
),
102+
),
97103
);
98104
});
99105

@@ -166,7 +172,7 @@ and do not format to also bump the runtimeVersion.''',
166172
// roll traffic backwards.
167173
// Avoid this by temporarily hardcoding gcBeforeRuntimeVersion to not be
168174
// the last version of acceptedRuntimeVersions.
169-
expect(gcBeforeRuntimeVersion != runtimeVersion, isTrue);
175+
expect(gcBeforeRuntimeVersion, isNot(runtimeVersion));
170176
});
171177

172178
scopedTest('GC is returning correct values for known versions', () {

pkg/image_proxy/lib/image_proxy_service.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ Future<shelf.Response> handler(shelf.Request request) async {
173173
});
174174
}
175175

176-
request.headers.add('user-agent', 'Image proxy for pub.dev. See https://github.com/dart-lang/pub-dev/pkg/image-proxy. If you have any issues, contact [email protected].');
176+
request.headers.add(
177+
'user-agent',
178+
'Image proxy for pub.dev. See https://github.com/dart-lang/pub-dev/pkg/image-proxy. If you have any issues, contact [email protected].',
179+
);
177180
request.followRedirects = false;
178181
scheduleRequestTimeout();
179182
var response = await request.close();

0 commit comments

Comments
 (0)