Skip to content

Commit 85522a9

Browse files
authored
Merge branch 'main' into feat/dart-frog-create
2 parents b9ab1c0 + c914d4c commit 85522a9

36 files changed

+581
-511
lines changed

packages/dart_frog_cli/e2e/test/daemon/dev_server_domain_test.dart

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ void main() {
191191
);
192192
});
193193

194-
testServer(port: project1Server2Port, 'GET / on project 1 server 2',
195-
(host) async {
194+
testServer(port: project1Server2Port, 'GET / on project 1 server 2', (
195+
host,
196+
) async {
196197
final response = await http.get(Uri.parse(host));
197198
expect(response.statusCode, equals(HttpStatus.ok));
198199
expect(response.body, equals('Welcome to Dart Frog!'));
@@ -233,8 +234,9 @@ void main() {
233234
expect(response.isSuccess, isTrue);
234235
});
235236

236-
testServer(port: project2ServerPort, 'GET /new_route on project 2',
237-
(host) async {
237+
testServer(port: project2ServerPort, 'GET /new_route on project 2', (
238+
host,
239+
) async {
238240
final response = await http.get(Uri.parse(host));
239241
expect(response.statusCode, equals(HttpStatus.ok));
240242
expect(response.headers, contains('date'));
@@ -245,27 +247,27 @@ void main() {
245247
});
246248

247249
test('try staggered-stop a dev server on project 1', () async {
248-
final (response1, response2) =
249-
await daemonStdio.sendStaggeredDaemonRequest(
250-
(
251-
DaemonRequest(
252-
id: '${++requestCount}',
253-
domain: 'dev_server',
254-
method: 'stop',
255-
params: {
256-
'applicationId': project1Server1Id,
257-
},
258-
),
259-
DaemonRequest(
260-
id: '${++requestCount}',
261-
domain: 'dev_server',
262-
method: 'stop',
263-
params: {
264-
'applicationId': project1Server1Id,
265-
},
266-
),
267-
),
268-
);
250+
final (response1, response2) = await daemonStdio
251+
.sendStaggeredDaemonRequest(
252+
(
253+
DaemonRequest(
254+
id: '${++requestCount}',
255+
domain: 'dev_server',
256+
method: 'stop',
257+
params: {
258+
'applicationId': project1Server1Id,
259+
},
260+
),
261+
DaemonRequest(
262+
id: '${++requestCount}',
263+
domain: 'dev_server',
264+
method: 'stop',
265+
params: {
266+
'applicationId': project1Server1Id,
267+
},
268+
),
269+
),
270+
);
269271

270272
expect(response1.isSuccess, isTrue);
271273
expect(response1.result!['exitCode'], equals(0));
@@ -305,16 +307,18 @@ void main() {
305307
});
306308

307309
testServer(
308-
// TODO(renancaraujo): this fails on linux: https://github.com/dart-frog-dev/dart_frog/issues/807
309-
skip: Platform.isLinux,
310-
'GET on project 1 server 1: connection refused', (host) async {
311-
final responseFuture = http.get(Uri.parse(host));
312-
313-
await expectLater(
314-
responseFuture,
315-
throwsA(isA<SocketException>()),
316-
);
317-
});
310+
// TODO(renancaraujo): this fails on linux: https://github.com/dart-frog-dev/dart_frog/issues/807
311+
skip: Platform.isLinux,
312+
'GET on project 1 server 1: connection refused',
313+
(host) async {
314+
final responseFuture = http.get(Uri.parse(host));
315+
316+
await expectLater(
317+
responseFuture,
318+
throwsA(isA<SocketException>()),
319+
);
320+
},
321+
);
318322

319323
testServer(
320324
port: project2ServerPort,

packages/dart_frog_cli/e2e/test/daemon/route_configuration_domain_test.dart

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -236,27 +236,27 @@ void main() {
236236
});
237237

238238
test('staggered-stop watcher', () async {
239-
final (response1, response2) =
240-
await daemonStdio.sendStaggeredDaemonRequest(
241-
(
242-
DaemonRequest(
243-
id: '${requestCount++}',
244-
domain: 'route_configuration',
245-
method: 'watcherStop',
246-
params: {
247-
'watcherId': projectWatcherId,
248-
},
249-
),
250-
DaemonRequest(
251-
id: '${requestCount++}',
252-
domain: 'route_configuration',
253-
method: 'watcherStop',
254-
params: {
255-
'watcherId': projectWatcherId,
256-
},
257-
),
258-
),
259-
);
239+
final (response1, response2) = await daemonStdio
240+
.sendStaggeredDaemonRequest(
241+
(
242+
DaemonRequest(
243+
id: '${requestCount++}',
244+
domain: 'route_configuration',
245+
method: 'watcherStop',
246+
params: {
247+
'watcherId': projectWatcherId,
248+
},
249+
),
250+
DaemonRequest(
251+
id: '${requestCount++}',
252+
domain: 'route_configuration',
253+
method: 'watcherStop',
254+
params: {
255+
'watcherId': projectWatcherId,
256+
},
257+
),
258+
),
259+
);
260260

261261
expect(response1.isSuccess, isTrue);
262262
expect(response1.result?['exitCode'], equals(0));

packages/dart_frog_cli/e2e/test/helpers/dart_frog_daemon.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ class DaemonStdioHelper {
6969
Duration timeout = _defaultTimeout,
7070
Matcher? withParamsThat,
7171
}) async {
72-
var wrappedMatcher = isA<DaemonEvent>()
73-
.having((e) => '${e.domain}.${e.event}', 'is $methodKey', methodKey);
72+
var wrappedMatcher = isA<DaemonEvent>().having(
73+
(e) => '${e.domain}.${e.event}',
74+
'is $methodKey',
75+
methodKey,
76+
);
7477

7578
if (withParamsThat != null) {
7679
wrappedMatcher = wrappedMatcher.having(
@@ -237,7 +240,7 @@ class DaemonStdioHelper {
237240
/// A matcher that matches a [DaemonMessage] to a daemon stdout line.
238241
class _MatchMessageToStdoutLine extends CustomMatcher {
239242
_MatchMessageToStdoutLine(Matcher matcher)
240-
: super('Message to stdout line', 'message', matcher);
243+
: super('Message to stdout line', 'message', matcher);
241244

242245
@override
243246
Object? featureValueOf(dynamic actual) {

packages/dart_frog_cli/e2e/test/helpers/dart_frog_new.dart

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,20 @@ import 'run_process.dart';
77
Future<void> dartFrogNewRoute(
88
String routePath, {
99
required Directory directory,
10-
}) =>
11-
_dartFrogNew(
12-
routePath: routePath,
13-
what: 'route',
14-
directory: directory,
15-
);
10+
}) => _dartFrogNew(
11+
routePath: routePath,
12+
what: 'route',
13+
directory: directory,
14+
);
1615

1716
Future<void> dartFrogNewMiddleware(
1817
String routePath, {
1918
required Directory directory,
20-
}) =>
21-
_dartFrogNew(
22-
routePath: routePath,
23-
what: 'middleware',
24-
directory: directory,
25-
);
19+
}) => _dartFrogNew(
20+
routePath: routePath,
21+
what: 'middleware',
22+
directory: directory,
23+
);
2624

2725
Future<void> _dartFrogNew({
2826
required String routePath,

packages/dart_frog_cli/e2e/test/helpers/files.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ final doesNotExist = FileExistsMatcher(isFalse);
1111

1212
class FileExistsMatcher extends CustomMatcher {
1313
FileExistsMatcher(Matcher matcher)
14-
: super(
15-
'File exists',
16-
'file exists',
17-
isA<File>().having((p) => p.existsSync(), 'exists', matcher),
18-
);
14+
: super(
15+
'File exists',
16+
'file exists',
17+
isA<File>().having((p) => p.existsSync(), 'exists', matcher),
18+
);
1919
}

packages/dart_frog_cli/e2e/test/new_test.dart

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ void main() {
6464
});
6565

6666
test('Creates a index route for an existing directory', () async {
67-
Directory(path.join(routesDirectory.path, 'nested'))
68-
.createSync(recursive: true);
67+
Directory(
68+
path.join(routesDirectory.path, 'nested'),
69+
).createSync(recursive: true);
6970

7071
await dartFrogNewRoute('/nested', directory: projectDirectory);
7172

@@ -118,8 +119,9 @@ void main() {
118119
'Creates route normally when there is a non-dart file with the same '
119120
'route path',
120121
() async {
121-
File(path.join(routesDirectory.path, 'something.py'))
122-
.createSync(recursive: true);
122+
File(
123+
path.join(routesDirectory.path, 'something.py'),
124+
).createSync(recursive: true);
123125

124126
await dartFrogNewRoute('/something', directory: projectDirectory);
125127

@@ -222,14 +224,16 @@ void main() {
222224
test('Excuse existing endpoints (existing rogue route)', () async {
223225
await dartFrogNewRoute('/existing_rogue', directory: projectDirectory);
224226

225-
Directory(path.join(routesDirectory.path, 'existing_rogue'))
226-
.createSync(recursive: true);
227+
Directory(
228+
path.join(routesDirectory.path, 'existing_rogue'),
229+
).createSync(recursive: true);
227230

228231
await expectLater(
229232
() =>
230233
dartFrogNewRoute('/existing_rogue', directory: projectDirectory),
231234
failsWith(
232-
stderr: 'Failed to create route: Rogue route detected. '
235+
stderr:
236+
'Failed to create route: Rogue route detected. '
233237
'Rename routes${slash}existing_rogue.dart to '
234238
'routes${slash}existing_rogue${slash}index.dart.',
235239
),
@@ -242,16 +246,18 @@ void main() {
242246
directory: projectDirectory,
243247
);
244248

245-
File(path.join(routesDirectory.path, 'conflicting_route/index.dart'))
246-
.createSync(recursive: true);
249+
File(
250+
path.join(routesDirectory.path, 'conflicting_route/index.dart'),
251+
).createSync(recursive: true);
247252

248253
await expectLater(
249254
() async => dartFrogNewRoute(
250255
'/conflicting_route',
251256
directory: projectDirectory,
252257
),
253258
failsWith(
254-
stderr: 'Failed to create route: '
259+
stderr:
260+
'Failed to create route: '
255261
'Route conflict detected. '
256262
'routes${slash}conflicting_route.dart and '
257263
'routes${slash}conflicting_route${slash}index.dart '
@@ -384,7 +390,8 @@ void main() {
384390
directory: projectDirectory,
385391
),
386392
failsWith(
387-
stderr: 'There is already a middleware at '
393+
stderr:
394+
'There is already a middleware at '
388395
'routes${slash}existing_middleware${slash}_middleware.dart',
389396
),
390397
);
@@ -406,7 +413,8 @@ void main() {
406413
directory: projectDirectory,
407414
),
408415
failsWith(
409-
stderr: 'Failed to create middleware: '
416+
stderr:
417+
'Failed to create middleware: '
410418
'Duplicate parameter name found: id',
411419
),
412420
);
@@ -445,45 +453,51 @@ void main() {
445453
test('Excuse middleware creation upon existing rogue routes', () async {
446454
await dartFrogNewRoute('/existing_rogue', directory: projectDirectory);
447455

448-
Directory(path.join(routesDirectory.path, 'existing_rogue'))
449-
.createSync(recursive: true);
456+
Directory(
457+
path.join(routesDirectory.path, 'existing_rogue'),
458+
).createSync(recursive: true);
450459

451460
await expectLater(
452461
() async => dartFrogNewMiddleware(
453462
'/existing_rogue',
454463
directory: projectDirectory,
455464
),
456465
failsWith(
457-
stderr: 'Failed to create middleware: Rogue route detected. '
466+
stderr:
467+
'Failed to create middleware: Rogue route detected. '
458468
'Rename routes${slash}existing_rogue.dart to '
459469
'routes${slash}existing_rogue${slash}index.dart.',
460470
),
461471
);
462472
});
463473

464-
test('Excuse middleware creation upon existing route conflicts',
465-
() async {
466-
await dartFrogNewRoute(
467-
'/conflicting_route',
468-
directory: projectDirectory,
469-
);
470-
471-
File(path.join(routesDirectory.path, 'conflicting_route/index.dart'))
472-
.createSync(recursive: true);
473-
474-
await expectLater(
475-
() async => dartFrogNewMiddleware(
474+
test(
475+
'Excuse middleware creation upon existing route conflicts',
476+
() async {
477+
await dartFrogNewRoute(
476478
'/conflicting_route',
477479
directory: projectDirectory,
478-
),
479-
failsWith(
480-
stderr: 'Failed to create middleware: Route conflict detected. '
481-
'routes${slash}conflicting_route.dart and '
482-
'routes${slash}conflicting_route${slash}index.dart both '
483-
'resolve to /conflicting_route.',
484-
),
485-
);
486-
});
480+
);
481+
482+
File(
483+
path.join(routesDirectory.path, 'conflicting_route/index.dart'),
484+
).createSync(recursive: true);
485+
486+
await expectLater(
487+
() async => dartFrogNewMiddleware(
488+
'/conflicting_route',
489+
directory: projectDirectory,
490+
),
491+
failsWith(
492+
stderr:
493+
'Failed to create middleware: Route conflict detected. '
494+
'routes${slash}conflicting_route.dart and '
495+
'routes${slash}conflicting_route${slash}index.dart both '
496+
'resolve to /conflicting_route.',
497+
),
498+
);
499+
},
500+
);
487501
});
488502
});
489503
}

0 commit comments

Comments
 (0)