forked from serverpod/serverpod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Support named and optional args in test tools (serverpod#2784)
- Loading branch information
1 parent
a6ec360
commit 387ff78
Showing
11 changed files
with
1,595 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
tests/serverpod_test_server/lib/src/endpoints/method_signature_permutations.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import 'package:serverpod/serverpod.dart'; | ||
|
||
class MethodSignaturePermutationsEndpoint extends Endpoint { | ||
Future<String> echoPositionalArg( | ||
Session session, | ||
String string, | ||
) async { | ||
return string; | ||
} | ||
|
||
Future<String> echoNamedArg( | ||
Session session, { | ||
required String string, | ||
}) async { | ||
return string; | ||
} | ||
|
||
Future<String?> echoNullableNamedArg( | ||
Session session, { | ||
String? string, | ||
}) async { | ||
return string; | ||
} | ||
|
||
Future<String?> echoOptionalArg( | ||
Session session, [ | ||
String? string, | ||
]) async { | ||
return string; | ||
} | ||
|
||
Future<List<String?>> echoPositionalAndNamedArgs( | ||
Session session, | ||
String string1, { | ||
required String string2, | ||
}) async { | ||
return [string1, string2]; | ||
} | ||
|
||
Future<List<String?>> echoPositionalAndNullableNamedArgs( | ||
Session session, | ||
String string1, { | ||
String? string2, | ||
}) async { | ||
return [string1, string2]; | ||
} | ||
|
||
Future<List<String?>> echoPositionalAndOptionalArgs( | ||
Session session, String string1, | ||
[String? string2]) async { | ||
return [string1, string2]; | ||
} | ||
|
||
Stream<String> echoNamedArgStream( | ||
Session session, { | ||
required Stream<String> strings, | ||
}) async* { | ||
await for (var string in strings) { | ||
yield string; | ||
} | ||
} | ||
|
||
Future<String> echoNamedArgStreamAsFuture( | ||
Session session, { | ||
required Stream<String> strings, | ||
}) async { | ||
return strings.first; | ||
} | ||
|
||
Stream<String> echoPositionalArgStream( | ||
Session session, Stream<String> strings) async* { | ||
await for (var string in strings) { | ||
yield string; | ||
} | ||
} | ||
|
||
Future<String> echoPositionalArgStreamAsFuture( | ||
Session session, Stream<String> strings) async { | ||
return strings.first; | ||
} | ||
} |
Oops, something went wrong.