mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-11-04 07:15:46 +00:00 
			
		
		
		
	Improved API connection testing
This commit is contained in:
		@@ -66,15 +66,28 @@ void main() {
 | 
				
			|||||||
      if (profile != null) {
 | 
					      if (profile != null) {
 | 
				
			||||||
        profile.server = "http://localhost:5555";
 | 
					        profile.server = "http://localhost:5555";
 | 
				
			||||||
        await UserProfileDBManager().updateProfile(profile);
 | 
					        await UserProfileDBManager().updateProfile(profile);
 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bool result = await api.connectToServer();
 | 
					        bool result = await api.connectToServer();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        assert(!result);
 | 
					        assert(!result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // TODO: Test the the right 'error message' is returned
 | 
					        // 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);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // TODO: Test incorrect login details
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user