Skip to content

Commit

Permalink
test: use coverage helper to ignore test codes
Browse files Browse the repository at this point in the history
  • Loading branch information
adamanteye committed Oct 14, 2024
1 parent bb3c427 commit aa85c73
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ rand = "0.8.5"
regex = "1.11.0"
uuid = "1.10.0"
# With llvm-cov
coverage-helper = "0.1"
coverage-helper = "0.2"

[package]
name = "veloquent-core"
Expand All @@ -52,6 +52,9 @@ license.workspace = true
publish.workspace = true
authors.workspace = true

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] }

[dependencies]
axum = { workspace = true }
sea-orm = { workspace = true, features = [
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct Config {
#[cfg(test)]
mod test {
use super::*;
use coverage_helper::test;

#[test]
fn test_config_file() {
Expand Down
1 change: 1 addition & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl IntoResponse for AppError {
#[cfg(test)]
mod test {
use super::*;
use coverage_helper::test;

#[test]
fn test_std_error_to_response() {
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(missing_docs)]
#![cfg_attr(all(coverage_nightly, test), feature(coverage_attribute))]

//! Veloquent 后端服务
//!
Expand Down
1 change: 1 addition & 0 deletions src/utility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ where
#[cfg(test)]
mod test {
use super::*;
use coverage_helper::test;

#[test]
fn test_hash_and_salt() {
Expand Down
4 changes: 3 additions & 1 deletion src/view/user_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ impl From<user::Model> for UserProfile {
#[cfg(test)]
mod test {
use super::*;
use coverage_helper::test;

#[test]
fn test_profile_from_entity() {
let created_at = chrono::Utc::now().naive_utc();
Expand All @@ -78,8 +80,8 @@ mod test {
phone: String::default(),
created_at,
gender: 0,
avatar: uuid::Uuid::default().to_string(),
alias: String::default(),
avatar: String::default(),
bio: String::default(),
link: String::default(),
}
Expand Down
2 changes: 2 additions & 0 deletions src/view/user_register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ pub async fn register_handler(
#[cfg(test)]
mod test {
use super::*;
use coverage_helper::test;

#[test]
fn test_empty_user_or_password() {
let p = r#"{"name":"","password":""}"#;
Expand Down

0 comments on commit aa85c73

Please sign in to comment.