mod common;
use apollo_errors::Error as ErrorTrait;
use common::{ErrorWithFields, SimpleError};
use insta::assert_snapshot;
#[test]
fn test_simple_error_text() {
let error = SimpleError::Simple;
let text = error.to_text();
assert_snapshot!(text, @"[errors::simple] Something went wrong");
}
#[test]
fn test_another_error_text() {
let error = SimpleError::Another;
let text = error.to_text();
assert_snapshot!(text, @"[errors::another] Another error occurred");
}
#[test]
fn test_error_with_fields_text() {
let error = ErrorWithFields::InvalidPort {
port: 8080,
config_file: "/etc/config.toml".to_string(),
};
let text = error.to_text();
assert_snapshot!(text, @"[config::invalid_port] Invalid port");
}
#[test]
fn test_text_with_interpolated_message() {
use common::ConfigStructError;
let error = ConfigStructError {
port: 8080,
config_path: "/etc/config.toml".to_string(),
};
let text = error.to_text();
assert_snapshot!(text, @"[structs::config_error] Configuration error: invalid port 8080");
}