/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use tnipv_lint::lints::preamble::RequireReferenced; use tnipv_lint::reporters::Text; use tnipv_lint::Linter; #[tokio::test] async fn valid() { let src = r#"--- header: Extension of TNIP-44 other: 1234, 44, 55 --- hello world"#; let reports = Linter::>::default() .clear_lints() .deny( "preamble-req-ref", RequireReferenced { name: "header", requires: "other", }, ) .check_slice(None, src) .run() .await .unwrap() .into_inner(); assert_eq!(reports, ""); } #[tokio::test] async fn unicode() { let src = r#"--- header: Exténsion of TNIP-9999 ánd TNIP-44 other: 1234, 55 --- hello world"#; let reports = Linter::>::default() .clear_lints() .deny( "preamble-req-ref", RequireReferenced { name: "header", requires: "other", }, ) .check_slice(None, src) .run() .await .unwrap() .into_inner(); assert_eq!( reports, r#"error[preamble-req-ref]: proposals mentioned in preamble header `header` must appear in `other` | 2 | header: Exténsion of TNIP-9999 ánd TNIP-44 | ^^^^^^^^^ mentioned here | ^^^^^^^ mentioned here | "# ); } #[tokio::test] async fn one_missing() { let src = r#"--- header: Extension of TNIP-9999 and TNIP-44 other: 1234, 44, 55 --- hello world"#; let reports = Linter::>::default() .clear_lints() .deny( "preamble-req-ref", RequireReferenced { name: "header", requires: "other", }, ) .check_slice(None, src) .run() .await .unwrap() .into_inner(); assert_eq!( reports, r#"error[preamble-req-ref]: proposals mentioned in preamble header `header` must appear in `other` | 2 | header: Extension of TNIP-9999 and TNIP-44 | ^^^^^^^^^ mentioned here | "# ); } #[tokio::test] async fn two_missing() { let src = r#"--- header: Extension of TNIP-9999 and TNIP-45 other: 1234, 44, 55 --- hello world"#; let reports = Linter::>::default() .clear_lints() .deny( "preamble-req-ref", RequireReferenced { name: "header", requires: "other", }, ) .check_slice(None, src) .run() .await .unwrap() .into_inner(); assert_eq!( reports, r#"error[preamble-req-ref]: proposals mentioned in preamble header `header` must appear in `other` | 2 | header: Extension of TNIP-9999 and TNIP-45 | ^^^^^^^^^ mentioned here | ^^^^^^^ mentioned here | "# ); }