added a test for excluding users

This commit is contained in:
Theis
2024-03-04 22:47:23 +01:00
parent 872cd7b5c0
commit ded0dc8779
+18 -3
View File
@@ -3,6 +3,7 @@ package main
import ( import (
"os" "os"
"os/exec" "os/exec"
"strings"
"testing" "testing"
) )
@@ -53,6 +54,7 @@ func Test_add_all(t *testing.T) {
for k := range users { for k := range users {
delete(users, k) delete(users, k)
} }
sb.Reset()
users["test1"] = user{username: "test1", email: "test1"} users["test1"] = user{username: "test1", email: "test1"}
users["test2"] = user{username: "test2", email: "test2"} users["test2"] = user{username: "test2", email: "test2"}
users["test3"] = user{username: "test3", email: "test3"} users["test3"] = user{username: "test3", email: "test3"}
@@ -60,8 +62,23 @@ func Test_add_all(t *testing.T) {
add_x_users([]string{}) add_x_users([]string{})
commit := sb_build() commit := sb_build()
if !strings.Contains(commit, "\nCo-authored-by: test1 <test1>") ||
!strings.Contains(commit, "\nCo-authored-by: test2 <test2>") ||
!strings.Contains(commit, "\nCo-authored-by: test3 <test3>") {
t.Fatalf("String built incorrectly. Strings did not match: Created -> %s Expected -> Co-authored-by: test <test>",commit)
}
}
if commit != "\nCo-authored-by: test <test>\nCo-authored-by: test1 <test1>\nCo-authored-by: test2 <test2>\nCo-authored-by: test3 <test3>" { func Test_exclude_user(t *testing.T) {
// Reusing users map from last test
excludeMode := []string{"test1"}
sb.Reset()
add_x_users(excludeMode)
commit := sb_build()
if strings.Contains(commit, "\nCo-authored-by: test1 <test1>") {
t.Fatalf("String built incorrectly. Strings did not match: Created -> %s Expected -> Co-authored-by: test <test>",commit) t.Fatalf("String built incorrectly. Strings did not match: Created -> %s Expected -> Co-authored-by: test <test>",commit)
} }
} }
@@ -69,5 +86,3 @@ func Test_add_all(t *testing.T) {