From 8374b6c59088259a8f415774ebc6d7151098ac41 Mon Sep 17 00:00:00 2001 From: Garrett Bischof Date: Sat, 12 Apr 2025 12:08:46 -0400 Subject: [PATCH] update connection to lemmy --- test/config.example.dart | 2 +- test/v4_test.dart | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 test/v4_test.dart diff --git a/test/config.example.dart b/test/config.example.dart index 1331fbc..a3d38cd 100644 --- a/test/config.example.dart +++ b/test/config.example.dart @@ -5,7 +5,7 @@ String version = 'v4'; /// The instance to connect to. By default, it will use the docker container port. -String instance = 'localhost:1236'; +String instance = 'proxy:1236'; /// The scheme to use. By default, it will use HTTP. String scheme = 'http'; diff --git a/test/v4_test.dart b/test/v4_test.dart new file mode 100644 index 0000000..63b5c13 --- /dev/null +++ b/test/v4_test.dart @@ -0,0 +1,33 @@ +import 'package:http/http.dart'; +import 'package:test/test.dart'; + +import 'package:lemmy_dart_client/src/client/client.dart'; + +// Import the auth token from the config file +import 'config.dart'; + +void main() { + late LemmyClient client; + + setUpAll(() async { + client = await LemmyClient.initialize( + instance: instance, + version: version, + scheme: scheme, + ); + }); + + group('Client', () { + test('should fetch the proper information when initialized', () async { + expect(client.site.info, isNotNull); + expect(client.account.info, isNull); + }); + + test('should fail when an invalid instance is given', () async { + expect( + () async => await LemmyClient.initialize(instance: 'invalid'), + throwsA(isA()), + ); + }); + }); +}