Skip to content

Commit ca2efa9

Browse files
reyortiz3claude
andcommitted
Use mainBranchName and testAuthorEmail constants in git tests
Replace raw "main" and "test@example.com" string literals with the existing/new named constants to fix the remaining goconst violations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c5c9591 commit ca2efa9

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

pkg/git/client_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ func TestDefaultGitClient_Clone_Errors(t *testing.T) {
3333
config CloneConfig
3434
}{
3535
{name: "invalid URL", config: CloneConfig{URL: "invalid-url"}},
36-
{name: "conflicting branch and tag", config: CloneConfig{URL: testRepoURL, Branch: "main", Tag: "v1.0"}},
37-
{name: "conflicting branch and commit", config: CloneConfig{URL: testRepoURL, Branch: "main", Commit: testCommitHash}},
36+
{name: "conflicting branch and tag", config: CloneConfig{URL: testRepoURL, Branch: mainBranchName, Tag: "v1.0"}},
37+
{name: "conflicting branch and commit", config: CloneConfig{URL: testRepoURL, Branch: mainBranchName, Commit: testCommitHash}},
3838
{name: "conflicting tag and commit", config: CloneConfig{URL: testRepoURL, Tag: "v1.0", Commit: testCommitHash}},
39-
{name: "all three refs set", config: CloneConfig{URL: testRepoURL, Branch: "main", Tag: "v1.0", Commit: testCommitHash}},
39+
{name: "all three refs set", config: CloneConfig{URL: testRepoURL, Branch: mainBranchName, Tag: "v1.0", Commit: testCommitHash}},
4040
}
4141

4242
for _, tt := range tests {
@@ -171,13 +171,13 @@ func TestCloneConfig_Validate(t *testing.T) {
171171
wantErr bool
172172
}{
173173
{name: "URL only", config: CloneConfig{URL: testRepoURL}, wantErr: false},
174-
{name: "branch only", config: CloneConfig{URL: "u", Branch: "main"}, wantErr: false},
174+
{name: "branch only", config: CloneConfig{URL: "u", Branch: mainBranchName}, wantErr: false},
175175
{name: "tag only", config: CloneConfig{URL: "u", Tag: "v1"}, wantErr: false},
176176
{name: "commit only", config: CloneConfig{URL: "u", Commit: testShortHash}, wantErr: false},
177-
{name: "branch+tag", config: CloneConfig{URL: "u", Branch: "main", Tag: "v1"}, wantErr: true},
178-
{name: "branch+commit", config: CloneConfig{URL: "u", Branch: "main", Commit: testShortHash}, wantErr: true},
177+
{name: "branch+tag", config: CloneConfig{URL: "u", Branch: mainBranchName, Tag: "v1"}, wantErr: true},
178+
{name: "branch+commit", config: CloneConfig{URL: "u", Branch: mainBranchName, Commit: testShortHash}, wantErr: true},
179179
{name: "tag+commit", config: CloneConfig{URL: "u", Tag: "v1", Commit: testShortHash}, wantErr: true},
180-
{name: "all three", config: CloneConfig{URL: "u", Branch: "main", Tag: "v1", Commit: testShortHash}, wantErr: true},
180+
{name: "all three", config: CloneConfig{URL: "u", Branch: mainBranchName, Tag: "v1", Commit: testShortHash}, wantErr: true},
181181
}
182182

183183
for _, tt := range tests {

pkg/git/integration_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import (
1515
"github.com/stretchr/testify/require"
1616
)
1717

18-
const mainBranchName = "main"
18+
const (
19+
mainBranchName = "main"
20+
testAuthorEmail = "test@example.com"
21+
)
1922

2023
// initTestRepo creates a local git repo with an initial commit containing the given files.
2124
// Returns the repo directory path.
@@ -36,7 +39,7 @@ func initTestRepo(t *testing.T, files map[string]string) string {
3639
}
3740

3841
_, err = wt.Commit("Initial commit", &gogit.CommitOptions{
39-
Author: &object.Signature{Name: testAuthorName, Email: "test@example.com"},
42+
Author: &object.Signature{Name: testAuthorName, Email: testAuthorEmail},
4043
})
4144
require.NoError(t, err)
4245

@@ -99,7 +102,7 @@ func TestDefaultGitClient_CloneWithBranch(t *testing.T) {
99102
_, err = wt.Add("feature.txt")
100103
require.NoError(t, err)
101104
_, err = wt.Commit("Add feature", &gogit.CommitOptions{
102-
Author: &object.Signature{Name: testAuthorName, Email: "test@example.com"},
105+
Author: &object.Signature{Name: testAuthorName, Email: testAuthorEmail},
103106
})
104107
require.NoError(t, err)
105108

@@ -142,7 +145,7 @@ func TestDefaultGitClient_CloneWithTag(t *testing.T) {
142145
_, err = wt.Add("v2.txt")
143146
require.NoError(t, err)
144147
_, err = wt.Commit("Post-tag commit", &gogit.CommitOptions{
145-
Author: &object.Signature{Name: testAuthorName, Email: "test@example.com"},
148+
Author: &object.Signature{Name: testAuthorName, Email: testAuthorEmail},
146149
})
147150
require.NoError(t, err)
148151

@@ -186,7 +189,7 @@ func TestDefaultGitClient_CloneWithCommit(t *testing.T) {
186189
_, err = wt.Add("file2.txt")
187190
require.NoError(t, err)
188191
_, err = wt.Commit("Second commit", &gogit.CommitOptions{
189-
Author: &object.Signature{Name: testAuthorName, Email: "test@example.com"},
192+
Author: &object.Signature{Name: testAuthorName, Email: testAuthorEmail},
190193
})
191194
require.NoError(t, err)
192195

0 commit comments

Comments
 (0)