From cdeac137bf8bebf3130607bf4fa317041ced1af7 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 22 May 2022 08:38:34 +1000 Subject: [PATCH] Improved API connection testing --- test/api_test.dart | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/test/api_test.dart b/test/api_test.dart index 8a4195a2..3ede3504 100644 --- a/test/api_test.dart +++ b/test/api_test.dart @@ -66,15 +66,28 @@ void main() { if (profile != null) { profile.server = "http://localhost:5555"; await UserProfileDBManager().updateProfile(profile); + + bool result = await api.connectToServer(); + assert(!result); + + // TODO: Test the the right 'error message' is returned + // TODO: The request above should throw a 'SockeException' + + // Test incorrect login details + profile.server = "http://localhost:12345"; + profile.username = "invalidusername"; + + await UserProfileDBManager().updateProfile(profile); + + await api.connectToServer(); + assert(!result); + + // TODO: Test that the connection attempt above throws an authentication error + } else { + assert(false); } - bool result = await api.connectToServer(); - assert(!result); - - // TODO: Test the the right 'error message' is returned - - // TODO: Test incorrect login details });