zilliz 1.4.2

TUI and CLI tool for managing Zilliz Cloud clusters and Milvus operations
Documentation
use zilliz::cli::error_hints::get_error_hint;

#[test]
fn test_auth_error() {
    let hint = get_error_hint(Some(401), 0, "Unauthorized");
    assert!(hint.is_some());
    assert!(hint.unwrap().contains("API key"));
}

#[test]
fn test_error_code_80001() {
    let hint = get_error_hint(None, 80001, "some message");
    assert!(hint.is_some());
    assert!(hint.unwrap().contains("API key"));
}

#[test]
fn test_rate_limit() {
    let hint = get_error_hint(Some(429), 0, "Too many requests");
    assert!(hint.is_some());
    assert!(hint.unwrap().contains("Rate limit"));
}

#[test]
fn test_server_error() {
    let hint = get_error_hint(Some(502), 0, "Bad Gateway");
    assert!(hint.is_some());
    assert!(hint.unwrap().contains("Server error"));
}

#[test]
fn test_no_hint() {
    let hint = get_error_hint(Some(200), 0, "Success");
    assert!(hint.is_none());
}

#[test]
fn test_permission_denied_case_insensitive() {
    let hint = get_error_hint(None, 0, "PermissionDenied: access not allowed");
    assert!(hint.is_some());
    assert!(hint.unwrap().contains("Dedicated"));
}

#[test]
fn test_timeout_hint() {
    let hint = get_error_hint(None, 0, "Request Timed Out after 30s");
    assert!(hint.is_some());
    assert!(hint.unwrap().contains("timed out"));
}

#[test]
fn test_connection_hint() {
    let hint = get_error_hint(None, 0, "Connection refused");
    assert!(hint.is_some());
    assert!(hint.unwrap().contains("Connection failed"));
}