@@ -537,6 +537,57 @@ func TestParseRange(t *testing.T) {
537537 }
538538}
539539
540+ func TestParseMessage (t * testing.T ) {
541+ tests := []struct {
542+ description string
543+ msg string
544+ cfg * config.Config
545+ expectedCommits []* Commit
546+ expectedErr error
547+ }{
548+ {
549+ description : "it returns a valid commit" ,
550+ msg : "feat: a new thing" ,
551+ cfg : config .Default (),
552+ expectedCommits : []* Commit {
553+ {
554+ Id : "0" ,
555+ ShortId : "0" ,
556+ Type : "feat" ,
557+ Description : "a new thing" ,
558+ },
559+ },
560+ expectedErr : nil ,
561+ },
562+ {
563+ description : "it excludes a commit based on the config" ,
564+ msg : "revert the thing" ,
565+ cfg : & config.Config {
566+ Exclude : config.Exclude {
567+ Prefixes : util .NewCaseInsensitiveSet ([]string {"revert" }),
568+ },
569+ },
570+ expectedCommits : []* Commit {},
571+ expectedErr : nil ,
572+ },
573+ {
574+ description : "it returns an error for an invalid commit message" ,
575+ msg : "revert the thing" ,
576+ cfg : config .Default (),
577+ expectedCommits : []* Commit {},
578+ expectedErr : ErrSummary ("0" ),
579+ },
580+ }
581+
582+ for _ , test := range tests {
583+ t .Run (test .description , func (t * testing.T ) {
584+ commits , err := ParseMessage (test .msg , test .cfg )
585+ assert .Equal (t , test .expectedCommits , commits )
586+ assert .Equal (t , test .expectedErr , err )
587+ })
588+ }
589+ }
590+
540591func TestApplyPolicy (t * testing.T ) {
541592 commit := & Commit {
542593 Id : "0" ,
0 commit comments