Skip to content

Commit 88e051d

Browse files
committed
minor adjustments
1 parent 6a29a0b commit 88e051d

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

lib/src/token_source/caching.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ extension CachedTokenSource on TokenSourceConfigurable {
164164
/// - store: The store implementation to use for caching (defaults to in-memory store)
165165
/// - validator: A function to determine if cached credentials are still valid (defaults to JWT expiration check)
166166
/// - Returns: A caching token source that wraps this token source
167-
TokenSourceConfigurable cached({
167+
CachingTokenSource cached({
168168
TokenStore? store,
169169
TokenValidator? validator,
170170
}) =>

lib/src/token_source/custom.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,5 @@ class CustomTokenSource implements TokenSourceConfigurable {
3131
CustomTokenSource(CustomTokenFunction function) : _function = function;
3232

3333
@override
34-
Future<TokenSourceResponse> fetch([TokenRequestOptions? options]) async {
35-
final requestOptions = options ?? const TokenRequestOptions();
36-
return await _function(requestOptions);
37-
}
34+
Future<TokenSourceResponse> fetch(TokenRequestOptions options) async => _function(options);
3835
}

lib/src/token_source/token_source.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class TokenRequestOptions {
6161
participantIdentity: participantIdentity,
6262
participantMetadata: participantMetadata,
6363
participantAttributes: participantAttributes,
64-
roomConfiguration: agents != null ? RoomConfiguration(agents: agents) : null,
64+
roomConfiguration: RoomConfiguration(agents: agents),
6565
);
6666
}
6767

test/token/caching_token_source_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,7 @@ class _MockTokenSource implements TokenSourceConfigurable {
333333
_MockTokenSource(this._fetchFn);
334334

335335
@override
336-
Future<TokenSourceResponse> fetch([TokenRequestOptions? options]) {
337-
return _fetchFn(options ?? const TokenRequestOptions());
338-
}
336+
Future<TokenSourceResponse> fetch(TokenRequestOptions options) => _fetchFn(options);
339337
}
340338

341339
String _generateValidToken() {

test/token/endpoint_token_source_test.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void main() {
112112
expect(capturedRequest, isNotNull);
113113
expect(capturedRequest!.method, 'GET');
114114
// Body is always sent even for GET requests
115-
expect(capturedRequest!.body, '{}');
115+
expect(capturedRequest!.body, '{"room_config":{}}');
116116
});
117117

118118
test('accepts non-200 success responses', () async {
@@ -298,7 +298,9 @@ void main() {
298298

299299
final json = options.toRequest().toJson();
300300

301-
expect(json, isEmpty);
301+
expect(json.keys, contains('room_config'));
302+
expect(json['room_config'], isMap);
303+
expect((json['room_config'] as Map), isEmpty);
302304
});
303305

304306
test('only includes non-null fields', () {
@@ -313,6 +315,8 @@ void main() {
313315
expect(json.containsKey('room_name'), isTrue);
314316
expect(json.containsKey('participant_name'), isFalse);
315317
expect(json.containsKey('participant_identity'), isTrue);
318+
expect(json.containsKey('room_config'), isTrue);
319+
expect((json['room_config'] as Map), isEmpty);
316320
});
317321
});
318322

test/token/token_source_test.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import 'package:flutter_test/flutter_test.dart';
1818
import 'package:livekit_client/src/token_source/custom.dart';
1919
import 'package:livekit_client/src/token_source/jwt.dart';
2020
import 'package:livekit_client/src/token_source/literal.dart';
21-
import 'package:livekit_client/src/token_source/sandbox.dart';
2221
import 'package:livekit_client/src/token_source/room_configuration.dart';
22+
import 'package:livekit_client/src/token_source/sandbox.dart';
2323
import 'package:livekit_client/src/token_source/token_source.dart';
2424

2525
void main() {
@@ -354,7 +354,7 @@ void main() {
354354
expect(request.roomConfiguration!.agents![0].metadata, '{"key":"value"}');
355355
});
356356

357-
test('toRequest() creates null roomConfiguration when no agent fields', () {
357+
test('toRequest() creates empty roomConfiguration when no agent fields', () {
358358
const options = TokenRequestOptions(
359359
roomName: 'test-room',
360360
participantName: 'test-participant',
@@ -364,7 +364,8 @@ void main() {
364364

365365
expect(request.roomName, 'test-room');
366366
expect(request.participantName, 'test-participant');
367-
expect(request.roomConfiguration, isNull);
367+
expect(request.roomConfiguration, isNotNull);
368+
expect(request.roomConfiguration!.agents, isNull);
368369
});
369370

370371
test('TokenSourceRequest.toJson() produces correct wire format', () {

0 commit comments

Comments
 (0)