Skip to content

Commit

Permalink
api/backend: ignore coverage for non-testable code (#561)
Browse files Browse the repository at this point in the history
* ignore coverage for test related code

* add test for default config

* ignore config coverage

* ignore coverage for main related operations

* ignore coverage for router
  • Loading branch information
vnghia authored Dec 8, 2024
1 parent b4aebd3 commit 401534f
Show file tree
Hide file tree
Showing 70 changed files with 92 additions and 0 deletions.
1 change: 1 addition & 0 deletions nghe-api/src/auth/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ impl<'u, 't> From<token::Auth<'u, 't>> for Form<'u, 't> {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use rstest::rstest;

Expand Down
1 change: 1 addition & 0 deletions nghe-api/src/auth/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ mod serde {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use rstest::rstest;

Expand Down
1 change: 1 addition & 0 deletions nghe-api/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ emit_constant_serialize!(open_subsonic, bool, true);
emit_constant_serialize!(status_ok, str, "ok");

#[cfg(test)]
#[coverage(off)]
mod tests {
use serde_json::{json, to_value};

Expand Down
1 change: 1 addition & 0 deletions nghe-api/src/common/typed_uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ mod serde {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use fake::{Fake, Faker};
use rstest::rstest;
Expand Down
1 change: 1 addition & 0 deletions nghe-api/src/id3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub mod builder {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use nghe_proc_macro::api_derive;
use rstest::rstest;
Expand Down
1 change: 1 addition & 0 deletions nghe-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(adt_const_params)]
#![feature(coverage_attribute)]
#![feature(trait_alias)]

pub mod auth;
Expand Down
1 change: 1 addition & 0 deletions nghe-api/src/lists/get_album_list2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub struct Response {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use rstest::rstest;

Expand Down
1 change: 1 addition & 0 deletions nghe-api/src/media_annotation/scrobble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct Request {
pub struct Response;

#[cfg(test)]
#[coverage(off)]
mod tests {
use rstest::rstest;
use time::macros::datetime;
Expand Down
1 change: 1 addition & 0 deletions nghe-api/src/playlists/create_playlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ mod test {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use rstest::rstest;
use uuid::uuid;
Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/config/cover_art.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct CoverArt {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use strum::IntoEnumIterator;
use typed_path::Utf8NativePath;
Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/config/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub struct Filesystem {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use super::*;

Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/config/integration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct Integration {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use super::*;

Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/config/parsing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub struct Parsing {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use super::*;

Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/config/parsing/vorbis_comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ impl Artist {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use super::*;

Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/config/transcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct Transcode {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use typed_path::Utf8NativePath;

Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/database/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl Database {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use fake::{Dummy, Fake, Faker};
use rstest::rstest;
Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl Database {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use fake::{Fake, Faker};

Expand Down
2 changes: 2 additions & 0 deletions nghe-backend/src/file/audio/artist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ impl<'a> Artists<'a> {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use diesel::{QueryDsl, SelectableHelper};
use itertools::Itertools;
Expand Down Expand Up @@ -394,6 +395,7 @@ mod test {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use rstest::rstest;

Expand Down
2 changes: 2 additions & 0 deletions nghe-backend/src/file/audio/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl FromStr for Date {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use std::fmt::{Display, Formatter};

Expand Down Expand Up @@ -115,6 +116,7 @@ mod test {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use rstest::rstest;

Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/file/audio/duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ impl<D: Trait> Trait for Vec<D> {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use rstest::rstest;

Expand Down
2 changes: 2 additions & 0 deletions nghe-backend/src/file/audio/genre.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ impl Genres<'_> {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use diesel::SelectableHelper;
use futures_lite::{stream, StreamExt};
Expand Down Expand Up @@ -166,6 +167,7 @@ mod test {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use rstest::rstest;

Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/file/audio/information.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl Information<'_> {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use rstest::rstest;

Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/file/audio/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub struct Metadata<'a> {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use fake::{Fake, Faker};
use rstest::rstest;
Expand Down
2 changes: 2 additions & 0 deletions nghe-backend/src/file/audio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ impl File {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use std::io::Cursor;

Expand Down Expand Up @@ -127,6 +128,7 @@ mod test {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use fake::{Fake, Faker};
use isolang::Language;
Expand Down
2 changes: 2 additions & 0 deletions nghe-backend/src/file/audio/name_date_mbz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl Album<'_> {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use diesel::{ExpressionMethods, QueryDsl, SelectableHelper};
use diesel_async::RunQueryDsl;
Expand Down Expand Up @@ -111,6 +112,7 @@ mod test {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use fake::{Fake, Faker};
use itertools::Itertools;
Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/file/audio/position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl TrackDisc {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
#![allow(clippy::too_many_arguments)]

Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/file/audio/property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct Property {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use super::*;
use crate::file::audio::{self};
Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/file/picture/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ impl<'s> Picture<'s, 'static> {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use std::io::Cursor;

Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/filesystem/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ impl Trait for Impl<'_> {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use fake::{Fake, Faker};
use futures_lite::StreamExt;
Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/http/binary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ impl IntoResponse for Response {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use http_body_util::BodyExt;

Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/http/extract/auth/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ where
}

#[cfg(test)]
#[coverage(off)]
mod tests {
#![allow(unexpected_cfgs)]

Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/http/extract/auth/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ where
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use axum::http;
use axum_extra::headers::HeaderMapExt;
Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/http/extract/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ where
}

#[cfg(test)]
#[coverage(off)]
mod test {
#![allow(unexpected_cfgs)]

Expand Down
6 changes: 6 additions & 0 deletions nghe-backend/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![feature(adt_const_params)]
#![feature(anonymous_lifetime_in_impl_trait)]
#![feature(async_closure)]
#![feature(coverage_attribute)]
#![feature(duration_constructors)]
#![feature(if_let_guard)]
#![feature(integer_sign_cast)]
Expand All @@ -12,8 +13,10 @@
#![feature(str_as_str)]
#![feature(try_blocks)]

#[coverage(off)]
pub mod config;
mod database;
#[coverage(off)]
mod error;
mod file;
mod filesystem;
Expand All @@ -29,6 +32,7 @@ mod time;
mod transcode;

#[cfg(test)]
#[coverage(off)]
mod test;

use axum::Router;
Expand All @@ -44,6 +48,7 @@ use uuid::Uuid;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

#[coverage(off)]
pub fn init_tracing() -> Result<(), Error> {
color_eyre::install()?;

Expand All @@ -68,6 +73,7 @@ pub fn init_tracing() -> Result<(), Error> {
Ok(())
}

#[coverage(off)]
pub async fn build(config: config::Config) -> Router {
let filesystem =
filesystem::Filesystem::new(&config.filesystem.tls, &config.filesystem.s3).await;
Expand Down
3 changes: 3 additions & 0 deletions nghe-backend/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#![feature(coverage_attribute)]

use nghe_api::constant;
use nghe_backend::{build, config, init_tracing, migration};

#[coverage(off)]
#[tokio::main]
async fn main() {
init_tracing().unwrap();
Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/orm/albums/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ mod upsert {
}

#[cfg(test)]
#[coverage(off)]
mod test {
use super::*;

Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/orm/id3/album/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ pub mod query {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use diesel_async::RunQueryDsl;
use fake::{Fake, Faker};
Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/orm/id3/album/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub mod query {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use diesel_async::RunQueryDsl;
use fake::{Fake, Faker};
Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/orm/id3/album/short.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub mod query {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use diesel_async::RunQueryDsl;
use fake::{Fake, Faker};
Expand Down
1 change: 1 addition & 0 deletions nghe-backend/src/orm/id3/artist/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub mod query {
}

#[cfg(test)]
#[coverage(off)]
mod tests {
use diesel_async::RunQueryDsl;
use fake::{Fake, Faker};
Expand Down
Loading

0 comments on commit 401534f

Please sign in to comment.