Skip to content

Commit 2cb5485

Browse files
committed
testutils.ConfigAdd(): new helper function
1 parent c7b7671 commit 2cb5485

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

git_sizer_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,9 @@ func TestRefSelections(t *testing.T) {
263263
path := clonePath
264264

265265
for _, c := range p.config {
266-
cmd := testutils.GitCommand(
267-
t, path,
268-
"config", "--add", fmt.Sprintf("refgroup.mygroup.%s", c[0]), c[1],
266+
testutils.ConfigAdd(
267+
t, path, fmt.Sprintf("refgroup.mygroup.%s", c[0]), c[1],
269268
)
270-
err := cmd.Run()
271-
require.NoError(t, err)
272269
}
273270

274271
args := []string{"--show-refs", "--no-progress", "--json", "--json-version=2"}

internal/testutils/repoutils.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,12 @@ func AddAuthorInfo(cmd *exec.Cmd, timestamp *time.Time) {
144144
)
145145
*timestamp = timestamp.Add(60 * time.Second)
146146
}
147+
148+
// ConfigAdd adds a key-value pair to the gitconfig in the repository
149+
// at `repoPath`.
150+
func ConfigAdd(t *testing.T, repoPath string, key, value string) {
151+
t.Helper()
152+
153+
err := GitCommand(t, repoPath, "config", "--add", key, value).Run()
154+
require.NoError(t, err)
155+
}

0 commit comments

Comments
 (0)