refactor: extract base git config in tests
@@ -14,12 +14,7 @@ func TestUserGitconfigMap_EmptyString(t *testing.T) {
}
func TestUserGitconfigMap(t *testing.T) {
- d := `push.default=simple
- merge.conflictstyle=diff3
- pull.ff=only
- core.repositoryformatversion=0
- core.filemode=true
- core.bare=false`
+ d := gitConfig
expected := gitConfigMap(nil)
userGitconfigInfo := userGitconfigMap(d)
@@ -34,14 +29,8 @@ func TestUserGitconfigMap(t *testing.T) {
func TestUserGitconfigMap_WithEmptyLines(t *testing.T) {
d := `
user.name=Jane Doe
- push.default=simple
- merge.conflictstyle=diff3
- pull.ff=only
-
- core.repositoryformatversion=0
- core.filemode=true
- core.bare=false
+ ` + gitConfig + `
`
expected := gitConfigMap(map[string]string{
"user.name": "Jane Doe",
@@ -120,6 +109,14 @@ func checkAuthor(t *testing.T, input map[string]string, expected string) {
}
}
+var gitConfig = `push.default=simple
+ merge.conflictstyle=diff3
+ pull.ff=only
+ core.repositoryformatversion=0
+ core.filemode=true
+ core.bare=false
+ `
+
func gitConfigMap(input map[string]string) map[string]string {
res := map[string]string{
"push.default": "simple",
