Files

60 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

//! Quick test for gateway queue adapter
//! Tests only the queue_adapter and gateway_queue_adapter modules
#[test]
fn test_queue_adapter_trait_exists() {
// Just verify the trait is defined and can be used
use mem_cli::queue_adapter::QueueAdapter;
let _ = std::any::type_name::<dyn QueueAdapter>();
assert!(true);
}
#[test]
fn test_static_token_provider() {
use mem_cli::gateway_queue_adapter::StaticTokenProvider;
use mem_cli::gateway_queue_adapter::TokenProvider;
let provider = StaticTokenProvider::new("test-token-xyz".to_string());
assert_eq!(provider.token().unwrap(), "test-token-xyz");
}
#[test]
fn test_gateway_adapter_construction() {
use mem_cli::gateway_queue_adapter::GatewayQueueAdapter;
let adapter = GatewayQueueAdapter::with_static_token(
"https://api.riotpiao.com".to_string(),
"test-jwt".to_string(),
);
assert_eq!(adapter.queue_name("myproj"), "poimen-chunks-myproj");
}
#[test]
fn test_base64_helpers() {
let original = "hello world";
let encoded = base64::encode(original.as_bytes());
let decoded = String::from_utf8(base64::decode(encoded.as_bytes()).unwrap()).unwrap();
assert_eq!(original, decoded);
}
#[test]
fn test_queue_message_creation() {
use mem_cli::queue_adapter::QueueMessage;
use uuid::Uuid;
let msg = QueueMessage {
message_id: "msg-123".to_string(),
chunk_id: Uuid::new_v4(),
body: "test".to_string(),
receive_count: 0,
receipt_handle: "handle-123".to_string(),
project: "test".to_string(),
attributes: std::collections::HashMap::new(),
};
assert_eq!(msg.message_id, "msg-123");
assert_eq!(msg.receive_count, 0);
}