Skip to content

Commit a16cf82

Browse files
committed
style: Format network test files with dart format
CI runs `dart format --set-exit-if-changed` and rejected the two network test files added in the prior commit. Brings them into conformance.
1 parent 83199e9 commit a16cf82

2 files changed

Lines changed: 58 additions & 68 deletions

File tree

packages/dart/test/src/network/parse_client_test.dart

Lines changed: 37 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -69,41 +69,35 @@ void main() {
6969
client = _StubParseClient();
7070
});
7171

72-
test(
73-
'attaches X-Parse-Installation-Id by default. Matches iOS '
74-
'PFURLSessionCommandRunner behaviour — every request carries the '
75-
'install ID so parse-server can bind created _Session rows to the '
76-
'right installation and so destroyDuplicatedSessions can clean up '
77-
'prior sessions on the same install during login',
78-
() async {
79-
final Map<String, String>? headers = await client.exposedBuildHeaders(
80-
null,
81-
);
82-
83-
expect(headers, isNotNull);
84-
expect(headers![keyHeaderInstallationId], isNotEmpty);
85-
},
86-
);
87-
88-
test(
89-
'omits X-Parse-Installation-Id when caller passes '
90-
'sendInstallationId: false. The opt-out is forwarded by methods such '
91-
'as ParseUser.signUp(doNotSendInstallationID: true) for callers that '
92-
'cannot allow-list the header on their parse-server',
93-
() async {
94-
final Map<String, String>? headers = await client.exposedBuildHeaders(
95-
ParseNetworkOptions(sendInstallationId: false),
96-
);
72+
test('attaches X-Parse-Installation-Id by default. Matches iOS '
73+
'PFURLSessionCommandRunner behaviour — every request carries the '
74+
'install ID so parse-server can bind created _Session rows to the '
75+
'right installation and so destroyDuplicatedSessions can clean up '
76+
'prior sessions on the same install during login', () async {
77+
final Map<String, String>? headers = await client.exposedBuildHeaders(
78+
null,
79+
);
80+
81+
expect(headers, isNotNull);
82+
expect(headers![keyHeaderInstallationId], isNotEmpty);
83+
});
9784

98-
expect(
99-
headers?[keyHeaderInstallationId],
100-
isNull,
101-
reason:
102-
'sendInstallationId=false must suppress the header even when '
103-
'an install ID is available',
104-
);
105-
},
106-
);
85+
test('omits X-Parse-Installation-Id when caller passes '
86+
'sendInstallationId: false. The opt-out is forwarded by methods such '
87+
'as ParseUser.signUp(doNotSendInstallationID: true) for callers that '
88+
'cannot allow-list the header on their parse-server', () async {
89+
final Map<String, String>? headers = await client.exposedBuildHeaders(
90+
ParseNetworkOptions(sendInstallationId: false),
91+
);
92+
93+
expect(
94+
headers?[keyHeaderInstallationId],
95+
isNull,
96+
reason:
97+
'sendInstallationId=false must suppress the header even when '
98+
'an install ID is available',
99+
);
100+
});
107101

108102
test(
109103
'preserves a caller-supplied X-Parse-Installation-Id rather than '
@@ -120,20 +114,15 @@ void main() {
120114
},
121115
);
122116

123-
test(
124-
'merges caller-supplied headers with the install ID. Custom headers '
125-
'and the auto-attached install ID must coexist — neither side '
126-
'overrides the other',
127-
() async {
128-
final Map<String, String>? headers = await client.exposedBuildHeaders(
129-
ParseNetworkOptions(
130-
headers: <String, String>{'X-Custom': 'value'},
131-
),
132-
);
117+
test('merges caller-supplied headers with the install ID. Custom headers '
118+
'and the auto-attached install ID must coexist — neither side '
119+
'overrides the other', () async {
120+
final Map<String, String>? headers = await client.exposedBuildHeaders(
121+
ParseNetworkOptions(headers: <String, String>{'X-Custom': 'value'}),
122+
);
133123

134-
expect(headers!['X-Custom'], equals('value'));
135-
expect(headers[keyHeaderInstallationId], isNotEmpty);
136-
},
137-
);
124+
expect(headers!['X-Custom'], equals('value'));
125+
expect(headers[keyHeaderInstallationId], isNotEmpty);
126+
});
138127
});
139128
}

packages/dart/test/src/network/parse_dio_client_test.dart

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ class _HeaderCapturingAdapter implements HttpClientAdapter {
1616
Future<void>? cancelFuture,
1717
) async {
1818
requests.add(Map<String, dynamic>.from(options.headers));
19-
return ResponseBody.fromString('{}', 200, headers: <String, List<String>>{
20-
Headers.contentTypeHeader: <String>[Headers.jsonContentType],
21-
});
19+
return ResponseBody.fromString(
20+
'{}',
21+
200,
22+
headers: <String, List<String>>{
23+
Headers.contentTypeHeader: <String>[Headers.jsonContentType],
24+
},
25+
);
2226
}
2327

2428
@override
@@ -89,22 +93,19 @@ void main() {
8993
parseDioClient.client.httpClientAdapter = adapter;
9094
});
9195

92-
test(
93-
'headers returned by buildHeaders reach the outgoing request. This is '
94-
'the wiring check between the inherited helper (covered in detail by '
95-
'parse_client_test.dart) and dio\'s request pipeline — without it, a '
96-
'refactor that bypassed buildHeaders would silently drop install IDs '
97-
'on every request',
98-
() async {
99-
await parseDioClient.put('$serverUrl/classes/_User/abc', data: '{}');
100-
101-
expect(adapter.requests, hasLength(1));
102-
expect(
103-
adapter.requests.first[keyHeaderInstallationId],
104-
isNotEmpty,
105-
reason: 'install ID added by buildHeaders must reach the wire',
106-
);
107-
},
108-
);
96+
test('headers returned by buildHeaders reach the outgoing request. This is '
97+
'the wiring check between the inherited helper (covered in detail by '
98+
'parse_client_test.dart) and dio\'s request pipeline — without it, a '
99+
'refactor that bypassed buildHeaders would silently drop install IDs '
100+
'on every request', () async {
101+
await parseDioClient.put('$serverUrl/classes/_User/abc', data: '{}');
102+
103+
expect(adapter.requests, hasLength(1));
104+
expect(
105+
adapter.requests.first[keyHeaderInstallationId],
106+
isNotEmpty,
107+
reason: 'install ID added by buildHeaders must reach the wire',
108+
);
109+
});
109110
});
110111
}

0 commit comments

Comments
 (0)