-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sergio Castaño Arteaga <[email protected]>
- Loading branch information
Showing
7 changed files
with
250 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,208 @@ | ||
use super::{check, CheckInput}; | ||
use crate::github::{Commit, GitUser}; | ||
use indoc::indoc; | ||
|
||
#[test] | ||
fn check_no_signoff_single_commit_is_merge_commit() { | ||
let commit1 = Commit { | ||
is_merge: true, | ||
..Default::default() | ||
}; | ||
|
||
let input = CheckInput { | ||
commits: vec![commit1], | ||
}; | ||
let output = check(&input); | ||
|
||
assert!(output.commits_with_errors.is_empty()); | ||
} | ||
|
||
#[test] | ||
fn check_no_signoff_single_commit_author_is_bot() { | ||
let commit1 = Commit { | ||
author: Some(GitUser { | ||
is_bot: true, | ||
..Default::default() | ||
}), | ||
..Default::default() | ||
}; | ||
|
||
let input = CheckInput { | ||
commits: vec![commit1], | ||
}; | ||
let output = check(&input); | ||
|
||
assert!(output.commits_with_errors.is_empty()); | ||
} | ||
|
||
#[test] | ||
fn check_valid_signoff_single_commit_author_match() { | ||
let commit1 = Commit { | ||
author: Some(GitUser { | ||
name: "user1".to_string(), | ||
email: "[email protected]".to_string(), | ||
..Default::default() | ||
}), | ||
message: indoc! {r" | ||
Test commit message | ||
Signed-off-by: user1 <[email protected]> | ||
"} | ||
.to_string(), | ||
..Default::default() | ||
}; | ||
|
||
let input = CheckInput { | ||
commits: vec![commit1], | ||
}; | ||
let output = check(&input); | ||
|
||
assert!(output.commits_with_errors.is_empty()); | ||
} | ||
|
||
#[test] | ||
fn check_valid_signoff_single_commit_committer_match() { | ||
let commit1 = Commit { | ||
committer: Some(GitUser { | ||
name: "user1".to_string(), | ||
email: "[email protected]".to_string(), | ||
..Default::default() | ||
}), | ||
message: indoc! {r" | ||
Test commit message | ||
Signed-off-by: user1 <[email protected]> | ||
"} | ||
.to_string(), | ||
..Default::default() | ||
}; | ||
|
||
let input = CheckInput { | ||
commits: vec![commit1], | ||
}; | ||
let output = check(&input); | ||
|
||
assert!(output.commits_with_errors.is_empty()); | ||
} | ||
|
||
#[test] | ||
fn check_valid_signoff_single_commit_multiple_signoffs() { | ||
let commit1 = Commit { | ||
author: Some(GitUser { | ||
name: "user1".to_string(), | ||
email: "[email protected]".to_string(), | ||
..Default::default() | ||
}), | ||
message: indoc! {r" | ||
Test commit message | ||
Signed-off-by: userx <[email protected]> | ||
Signed-off-by: user1 <[email protected]> | ||
Signed-off-by: usery <[email protected]> | ||
"} | ||
.to_string(), | ||
..Default::default() | ||
}; | ||
|
||
let input = CheckInput { | ||
commits: vec![commit1], | ||
}; | ||
let output = check(&input); | ||
|
||
assert!(output.commits_with_errors.is_empty()); | ||
} | ||
|
||
#[test] | ||
fn check_valid_signoff_single_commit_signoff_case_insensitive() { | ||
let commit1 = Commit { | ||
author: Some(GitUser { | ||
name: "user1".to_string(), | ||
email: "[email protected]".to_string(), | ||
..Default::default() | ||
}), | ||
message: indoc! {r" | ||
Test commit message | ||
signed-off-by: USER1 <[email protected]> | ||
"} | ||
.to_string(), | ||
..Default::default() | ||
}; | ||
|
||
let input = CheckInput { | ||
commits: vec![commit1], | ||
}; | ||
let output = check(&input); | ||
|
||
assert!(output.commits_with_errors.is_empty()); | ||
} | ||
|
||
#[test] | ||
fn check_valid_signoff_single_commit_signoff_trailing_whitespace() { | ||
let commit1 = Commit { | ||
author: Some(GitUser { | ||
name: "user1".to_string(), | ||
email: "[email protected]".to_string(), | ||
..Default::default() | ||
}), | ||
message: "Test\n\nSigned-off-by: user1 <[email protected]> ".to_string(), | ||
..Default::default() | ||
}; | ||
|
||
let input = CheckInput { | ||
commits: vec![commit1], | ||
}; | ||
let output = check(&input); | ||
|
||
assert!(output.commits_with_errors.is_empty()); | ||
} | ||
|
||
#[test] | ||
fn check_valid_signoff_single_commit_email_contains_subdomain() { | ||
let commit1 = Commit { | ||
author: Some(GitUser { | ||
name: "user1".to_string(), | ||
email: "[email protected]".to_string(), | ||
..Default::default() | ||
}), | ||
message: indoc! {r" | ||
Test commit message | ||
Signed-off-by: user1 <[email protected]> | ||
"} | ||
.to_string(), | ||
..Default::default() | ||
}; | ||
|
||
let input = CheckInput { | ||
commits: vec![commit1], | ||
}; | ||
let output = check(&input); | ||
|
||
assert!(output.commits_with_errors.is_empty()); | ||
} | ||
|
||
#[test] | ||
fn check_valid_signoff_single_commit_email_contains_plus_alias() { | ||
let commit1 = Commit { | ||
author: Some(GitUser { | ||
name: "user1".to_string(), | ||
email: "[email protected]".to_string(), | ||
..Default::default() | ||
}), | ||
message: indoc! {r" | ||
Test commit message | ||
Signed-off-by: user1 <[email protected]> | ||
"} | ||
.to_string(), | ||
..Default::default() | ||
}; | ||
|
||
let input = CheckInput { | ||
commits: vec![commit1], | ||
}; | ||
let output = check(&input); | ||
|
||
assert!(output.commits_with_errors.is_empty()); | ||
} |
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