zus-discovery 1.1.4

Service discovery client for ZUS RPC framework with ZooServer integration
Documentation
//! ServiceEndpointPool Unit Tests
//!
//! These tests verify the endpoint pool behavior, health tracking,
//! and round-robin selection logic WITHOUT requiring a real ZooServer.

use zus_discovery::ServerActiveStatus;

// Note: We cannot easily instantiate ServiceEndpointPool without ZooClient
// But we can test the exposed behaviors through integration tests

/// Test that health status enum works correctly
#[test]
fn test_server_active_status_equality() {
  let ok1 = ServerActiveStatus::Ok;
  let ok2 = ServerActiveStatus::Ok;
  let fail1 = ServerActiveStatus::Fail;
  let fail2 = ServerActiveStatus::Fail;

  assert_eq!(ok1, ok2);
  assert_eq!(fail1, fail2);
  assert_ne!(ok1, fail1);
  assert_ne!(ok2, fail2);
}

/// Test that health status can be copied
#[test]
fn test_server_active_status_copy() {
  let original = ServerActiveStatus::Ok;
  let copied = original;

  assert_eq!(original, copied);
  assert_eq!(original, ServerActiveStatus::Ok);
}

/// Test health status debug formatting
#[test]
fn test_server_active_status_debug() {
  let ok_status = ServerActiveStatus::Ok;
  let fail_status = ServerActiveStatus::Fail;

  let ok_str = format!("{ok_status:?}");
  let fail_str = format!("{fail_status:?}");

  assert!(ok_str.contains("Ok"));
  assert!(fail_str.contains("Fail"));
}

// Integration-level tests that require ZooServer are in separate files
// These would test:
// - ServiceEndpointPool::new()
// - refresh_endpoints()
// - select_one_server() with real endpoints
// - update_health_status() with real endpoints
// - get_all_servers()