From 1914280428d67ec2ef9e5a990c949176b90cfdcb Mon Sep 17 00:00:00 2001 From: Vinzent Date: Tue, 13 Aug 2024 00:27:05 +0200 Subject: [PATCH] test: fix tests --- packages/postgrest/test/basic_test.dart | 16 ++++++++++++---- packages/postgrest/test/custom_http_client.dart | 7 +++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/postgrest/test/basic_test.dart b/packages/postgrest/test/basic_test.dart index 58d036c6..02f98275 100644 --- a/packages/postgrest/test/basic_test.dart +++ b/packages/postgrest/test/basic_test.dart @@ -91,11 +91,15 @@ void main() { final httpClient = CustomHttpClient(); final postgrest = PostgrestClient(rootUrl, httpClient: httpClient); - await postgrest.rpc('func').setHeader("myKey", "myValue").select(); + await postgrest + .rpc('empty-succ') + .setHeader("myKey", "myValue") + .select() + .head(); expect(httpClient.lastRequest!.headers, containsPair("myKey", "myValue")); // Other following requests should not have the header - await postgrest.rpc('func').select(); + await postgrest.rpc('empty-succ').select().head(); expect(httpClient.lastRequest!.headers, isNot(containsPair("myKey", "myValue"))); }); @@ -104,11 +108,15 @@ void main() { final httpClient = CustomHttpClient(); final postgrest = PostgrestClient(rootUrl, httpClient: httpClient); - await postgrest.from('users').setHeader("myKey", "myValue").select(); + await postgrest + .from('empty-succ') + .setHeader("myKey", "myValue") + .select() + .head(); expect(httpClient.lastRequest!.headers, containsPair("myKey", "myValue")); // Other following requests should not have the header - await postgrest.from('users').select(); + await postgrest.from('empty-succ').select().head(); expect(httpClient.lastRequest!.headers, isNot(containsPair("myKey", "myValue"))); }); diff --git a/packages/postgrest/test/custom_http_client.dart b/packages/postgrest/test/custom_http_client.dart index 850bc9e1..f2da3983 100644 --- a/packages/postgrest/test/custom_http_client.dart +++ b/packages/postgrest/test/custom_http_client.dart @@ -6,6 +6,13 @@ class CustomHttpClient extends BaseClient { Future send(BaseRequest request) async { lastRequest = request; + if (request.url.path.endsWith("empty-succ")) { + return StreamedResponse( + Stream.empty(), + 200, + request: request, + ); + } //Return custom status code to check for usage of this client. return StreamedResponse( request.finalize(),