@@ -126,6 +126,23 @@ void main() {
126126 functions = createFunctionsWithMockHandler (mockHandler);
127127 });
128128
129+ group ('app property' , () {
130+ test ('returns the app passed to the constructor' , () {
131+ final appName =
132+ 'functions-app-test-${DateTime .now ().microsecondsSinceEpoch }' ;
133+ final app = FirebaseApp .initializeApp (
134+ name: appName,
135+ options: const AppOptions (projectId: projectId),
136+ );
137+ addTearDown (() => FirebaseApp .deleteApp (app));
138+
139+ final f = Functions .internal (app);
140+
141+ expect (identical (f.app, app), isTrue);
142+ expect (f.app.name, equals (appName));
143+ });
144+ });
145+
129146 group ('taskQueue' , () {
130147 test ('creates TaskQueue with function name' , () {
131148 final queue = functions.taskQueue ('helloWorld' );
@@ -595,6 +612,52 @@ void main() {
595612 );
596613 });
597614 });
615+
616+ group ('experimental.uri' , () {
617+ test ('throws on invalid URI' , () {
618+ expect (
619+ () => TaskOptionsExperimental (uri: 'not-a-url' ),
620+ throwsA (
621+ isA <FirebaseFunctionsAdminException >().having (
622+ (e) => e.errorCode,
623+ 'errorCode' ,
624+ FunctionsClientErrorCode .invalidArgument,
625+ ),
626+ ),
627+ );
628+ });
629+
630+ test ('throws on URI with no scheme' , () {
631+ expect (
632+ () => TaskOptionsExperimental (uri: 'example.com/path' ),
633+ throwsA (isA <FirebaseFunctionsAdminException >()),
634+ );
635+ });
636+
637+ test ('accepts a valid HTTPS URI' , () {
638+ expect (
639+ () => TaskOptionsExperimental (uri: 'https://example.com/handler' ),
640+ returnsNormally,
641+ );
642+ });
643+
644+ test ('accepts a valid HTTP URI' , () {
645+ expect (
646+ () => TaskOptionsExperimental (uri: 'http://localhost:8080/handler' ),
647+ returnsNormally,
648+ );
649+ });
650+
651+ test ('accepts null URI' , () {
652+ expect (TaskOptionsExperimental .new , returnsNormally);
653+ });
654+
655+ test ('stores the URI value' , () {
656+ const uri = 'https://example.com/handler' ;
657+ final opts = TaskOptionsExperimental (uri: uri);
658+ expect (opts.uri, equals (uri));
659+ });
660+ });
598661 });
599662
600663 // ===========================================================================
@@ -1103,6 +1166,43 @@ void main() {
11031166 await app.close ();
11041167 }
11051168 });
1169+
1170+ test ('uses experimental.uri as the httpRequest URL' , () async {
1171+ Map <String , dynamic >? capturedTaskBody;
1172+ const customUri = 'https://custom.example.com/my-handler' ;
1173+
1174+ final authClient = await createTestAuthClient (
1175+ email: mockClientEmail,
1176+ apiHandler: (request) {
1177+ capturedTaskBody = jsonDecode (request.body) as Map <String , dynamic >;
1178+ return Response (
1179+ jsonEncode ({'name' : 'task/123' }),
1180+ 200 ,
1181+ headers: {'content-type' : 'application/json' },
1182+ );
1183+ },
1184+ );
1185+
1186+ final app = FirebaseApp .initializeApp (
1187+ name: 'experimental-uri-test-${DateTime .now ().microsecondsSinceEpoch }' ,
1188+ options: AppOptions (projectId: projectId, httpClient: authClient),
1189+ );
1190+
1191+ try {
1192+ final functions = Functions .internal (app);
1193+ final queue = functions.taskQueue ('helloWorld' );
1194+ final options = TaskOptions (
1195+ experimental: TaskOptionsExperimental (uri: customUri),
1196+ );
1197+ await queue.enqueue ({'data' : 'test' }, options);
1198+
1199+ final task = capturedTaskBody! ['task' ] as Map <String , dynamic >;
1200+ final httpRequest = task['httpRequest' ] as Map <String , dynamic >;
1201+ expect (httpRequest['url' ], equals (customUri));
1202+ } finally {
1203+ await app.close ();
1204+ }
1205+ });
11061206 });
11071207
11081208 // ===========================================================================
0 commit comments