-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: trim whitespace while validating DCO (#126)
Signed-off-by: Andrey Smirnov <[email protected]>
- Loading branch information
1 parent
57c9dbd
commit 0af31f8
Showing
2 changed files
with
43 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,48 @@ func TestConventionalCommitPolicy(t *testing.T) { | |
} | ||
} | ||
|
||
func TestValidateDCO(t *testing.T) { | ||
type testDesc struct { | ||
Name string | ||
CommitMessage string | ||
ExpectValid bool | ||
} | ||
|
||
for _, test := range []testDesc{ | ||
{ | ||
Name: "Valid DCO", | ||
CommitMessage: "something nice\n\nSigned-off-by: Foo Bar <[email protected]>\n\n", | ||
ExpectValid: true, | ||
}, | ||
{ | ||
Name: "Valid DCO with CRLF", | ||
CommitMessage: "something nice\r\n\r\nSigned-off-by: Foo Bar <[email protected]>\r\n\r\n", | ||
ExpectValid: true, | ||
}, | ||
{ | ||
Name: "No DCO", | ||
CommitMessage: "something nice\n\nnot signed\n", | ||
ExpectValid: false, | ||
}, | ||
} { | ||
t.Run(test.Name, func(tt *testing.T) { | ||
var report policy.Report | ||
|
||
ValidateDCO(&report, test.CommitMessage) | ||
|
||
if test.ExpectValid { | ||
if !report.Valid() { | ||
tt.Error("Report is invalid with valid DCP") | ||
} | ||
} else { | ||
if report.Valid() { | ||
tt.Error("Report is valid with invalid DCO") | ||
} | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func runCompliance() *policy.Report { | ||
c := &Commit{ | ||
Conventional: &Conventional{ | ||
|