mirror of
https://github.com/Slug-Boi/cocommit.git
synced 2026-05-13 12:45:47 +00:00
test: added a test for grouping
This commit is contained in:
@@ -17,20 +17,22 @@ type user struct {
|
||||
|
||||
// Map of all th users in the author file
|
||||
var users = make(map[string]user)
|
||||
|
||||
// String builder for building the commit message
|
||||
var sb strings.Builder
|
||||
|
||||
// Flag that can be toggled to include all users in a commit message (excluding defExclude)
|
||||
var all_flag = false
|
||||
|
||||
// DefaultExclude -> A list that contains users marked with ex meaning
|
||||
// they should not be included in all and negations
|
||||
var defExclude = []string{}
|
||||
|
||||
// Group map for adding people as a group
|
||||
var groups = make(map[string][]user)
|
||||
|
||||
|
||||
func main() {
|
||||
|
||||
|
||||
// Reads a shell env variable :: author_file
|
||||
authors := os.Getenv("author_file")
|
||||
|
||||
@@ -135,7 +137,6 @@ func main() {
|
||||
add_x_users(excludeMode)
|
||||
}
|
||||
|
||||
|
||||
// commit msg built
|
||||
commit := sb_build()
|
||||
|
||||
|
||||
@@ -98,6 +98,29 @@ func Test_exclude_by_default(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func Test_commit_with_grouping(t *testing.T) {
|
||||
for k := range groups {
|
||||
delete(groups, k)
|
||||
}
|
||||
|
||||
defExclude = []string{}
|
||||
|
||||
groups["test1"] = []user{users["test1"]}
|
||||
|
||||
excludeMode := group_selection(groups["test1"], []string{})
|
||||
|
||||
sb.Reset()
|
||||
|
||||
add_x_users(excludeMode)
|
||||
|
||||
commit := sb_build()
|
||||
|
||||
if commit != "\nCo-authored-by: test1 <test1>" {
|
||||
t.Fatalf("String built incorrectly. Strings did not match: Created -> %s Expected -> Co-authored-by: test <test>",commit)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user