-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
161 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub fn service_call_one() { | ||
println!("Service call one"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pub mod external_services; | ||
|
||
trait ContractOne{ | ||
fn do_stuff() -> String; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
mod dependency_parsing; | ||
pub mod dsl; | ||
mod engine; | ||
mod rules; | ||
pub mod rules; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#![cfg(test)] | ||
|
||
use rust_arkitect::dsl::Arkitect; | ||
use rust_arkitect::dsl::Project; | ||
use rust_arkitect::rules::must_not_depend_on::MustNotDependOnRule; | ||
use rust_arkitect::rules::rule::Rule; | ||
use std::fmt::{Display, Formatter}; | ||
|
||
struct TestRule; | ||
|
||
impl TestRule { | ||
fn new(_subject: &str, _dependencies: &[&str; 1]) -> TestRule { | ||
Self {} | ||
} | ||
} | ||
|
||
impl Display for TestRule { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
write!(f, "TestRule applied") | ||
} | ||
} | ||
|
||
impl Rule for TestRule { | ||
fn apply(&self, _file: &str) -> Result<(), String> { | ||
Ok(()) | ||
} | ||
|
||
fn is_applicable(&self, _file: &str) -> bool { | ||
true | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_custom_rule_execution() { | ||
let project = Project::new(); | ||
|
||
let rule = Box::new(TestRule::new("my_crate", &["a:crate::a_module"])); | ||
|
||
let result = Arkitect::ensure_that(project).complies_with(vec![rule]); | ||
|
||
assert!(result.is_ok()); | ||
} | ||
|
||
#[test] | ||
fn test_may_depend_on_standalone() { | ||
let project = Project::new(); | ||
|
||
let rule = Box::new(MustNotDependOnRule::new( | ||
"conversion::domain".to_string(), | ||
vec!["a:crate::a_module".to_string()], | ||
)); | ||
|
||
let result = Arkitect::ensure_that(project).complies_with(vec![rule]); | ||
|
||
assert!(result.is_ok()); | ||
} |