-
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.
fix: trim commit messages to first line only.
- Loading branch information
1 parent
03cb951
commit 35ff3ce
Showing
2 changed files
with
48 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package vcs | ||
|
||
import "testing" | ||
|
||
func Test_getShortMessage(t *testing.T) { | ||
type args struct { | ||
message string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
}{ | ||
{ | ||
name: "short message", | ||
args: args{ | ||
message: "long message\nwith multiple lines", | ||
}, | ||
want: "long message", | ||
}, | ||
{ | ||
name: "remove trailing newlines", | ||
args: args{ | ||
message: "commit message\n\n", | ||
}, | ||
want: "commit message", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := getShortMessage(tt.args.message); got != tt.want { | ||
t.Errorf("getShortMessage() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |