@@ -295,6 +295,48 @@ mod tests {
295
295
}
296
296
}
297
297
298
+ #[ tokio:: test]
299
+ async fn test_provider_detection ( ) {
300
+ use crate :: models:: { LocalProvider , ModelValidator } ;
301
+
302
+ println ! ( "🧪 Testing provider detection system..." ) ;
303
+
304
+ let validator = ModelValidator :: new ( ) ;
305
+
306
+ // Test provider detection for common endpoints
307
+ let ollama_provider = validator. detect_provider_type ( "localhost:11434" ) . await ;
308
+ let lmstudio_provider = validator. detect_provider_type ( "localhost:1234" ) . await ;
309
+ let custom_provider = validator. detect_provider_type ( "localhost:8080" ) . await ;
310
+
311
+ println ! ( "Provider detection results:" ) ;
312
+ println ! ( " Ollama (11434): {:?}" , ollama_provider) ;
313
+ println ! ( " LM Studio (1234): {:?}" , lmstudio_provider) ;
314
+ println ! ( " Custom (8080): {:?}" , custom_provider) ;
315
+
316
+ // Test fetching local models if Ollama is available
317
+ if ollama_provider == LocalProvider :: Ollama {
318
+ println ! ( "Testing local model fetching..." ) ;
319
+ match validator. fetch_local_models ( "localhost:11434" ) . await {
320
+ Ok ( models) => {
321
+ println ! ( "✅ Successfully fetched {} local models" , models. len( ) ) ;
322
+ for model in models. iter ( ) . take ( 3 ) {
323
+ println ! ( " - {} ({:?}, {})" , model. name, model. provider, model. size) ;
324
+ }
325
+ }
326
+ Err ( e) => {
327
+ println ! (
328
+ "⚠️ Could not fetch local models (Ollama not running): {}" ,
329
+ e
330
+ ) ;
331
+ }
332
+ }
333
+ } else {
334
+ println ! ( "⚠️ Ollama not detected, skipping local model test" ) ;
335
+ }
336
+
337
+ println ! ( "✅ Provider detection test completed!" ) ;
338
+ }
339
+
298
340
#[ test]
299
341
fn test_api_key_truncation ( ) {
300
342
// Test the API key display formatting (simulating the settings modal function)
0 commit comments