From e855eb55e792b1a2146eade58c33b80f17819700 Mon Sep 17 00:00:00 2001 From: Vinzent Date: Thu, 9 Jun 2022 21:04:57 +0200 Subject: [PATCH 1/3] fix: re-initialize client close #65 --- lib/src/supabase.dart | 3 +-- test/supabase_flutter_test.dart | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/src/supabase.dart b/lib/src/supabase.dart index 9c490746..c5e92316 100644 --- a/lib/src/supabase.dart +++ b/lib/src/supabase.dart @@ -1,6 +1,5 @@ import 'package:flutter/foundation.dart'; import 'package:supabase/supabase.dart'; - import 'package:supabase_flutter/src/local_storage.dart'; import 'package:supabase_flutter/src/supabase_auth.dart'; @@ -71,7 +70,7 @@ class Supabase { /// The supabase client for this instance /// /// Throws an error if [Supabase.initialize] was not called. - late final SupabaseClient client; + late SupabaseClient client; bool _debugEnable = false; /// Dispose the instance to free up resources. diff --git a/test/supabase_flutter_test.dart b/test/supabase_flutter_test.dart index 5478facf..5044adae 100644 --- a/test/supabase_flutter_test.dart +++ b/test/supabase_flutter_test.dart @@ -1,5 +1,4 @@ import 'package:flutter_test/flutter_test.dart'; - import 'package:supabase_flutter/supabase_flutter.dart'; import 'widget_test_stubs.dart'; @@ -22,6 +21,14 @@ void main() { expect(client, isNotNull); }); + test('can re-initialize client', () async { + final client = Supabase.instance.client; + Supabase.instance.dispose(); + final newClient = + Supabase.initialize(url: supabaseUrl, anonKey: supabaseKey); + expect(client, isNot(newClient)); + }); + test('can parse deeplink', () async { final uri = Uri.parse( "io.supabase.flutterdemo://login-callback#access_token=aaa&expires_in=3600&refresh_token=bbb&token_type=bearer&type=recovery", From 63facc58fc66f9a13b9458bdb1ae260b1db5a54d Mon Sep 17 00:00:00 2001 From: Vinzent Date: Thu, 16 Jun 2022 12:56:35 +0200 Subject: [PATCH 2/3] test: await supabase init --- test/supabase_flutter_test.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/supabase_flutter_test.dart b/test/supabase_flutter_test.dart index 5044adae..e64baf43 100644 --- a/test/supabase_flutter_test.dart +++ b/test/supabase_flutter_test.dart @@ -25,7 +25,8 @@ void main() { final client = Supabase.instance.client; Supabase.instance.dispose(); final newClient = - Supabase.initialize(url: supabaseUrl, anonKey: supabaseKey); + (await Supabase.initialize(url: supabaseUrl, anonKey: supabaseKey)) + .client; expect(client, isNot(newClient)); }); From 8e35c8e7de8163efea4c732448e34a022887dad2 Mon Sep 17 00:00:00 2001 From: Vinzent Date: Thu, 16 Jun 2022 15:45:54 +0200 Subject: [PATCH 3/3] test: use mock local storage for init --- test/supabase_flutter_test.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/supabase_flutter_test.dart b/test/supabase_flutter_test.dart index e64baf43..72db5687 100644 --- a/test/supabase_flutter_test.dart +++ b/test/supabase_flutter_test.dart @@ -24,9 +24,12 @@ void main() { test('can re-initialize client', () async { final client = Supabase.instance.client; Supabase.instance.dispose(); - final newClient = - (await Supabase.initialize(url: supabaseUrl, anonKey: supabaseKey)) - .client; + final newClient = (await Supabase.initialize( + url: supabaseUrl, + anonKey: supabaseKey, + localStorage: MockLocalStorage(), + )) + .client; expect(client, isNot(newClient)); });