Skip to content

Commit 996dc0d

Browse files
committed
lint and cleanup
1 parent 7f8caea commit 996dc0d

File tree

3 files changed

+30
-43
lines changed

3 files changed

+30
-43
lines changed

internal/cmd/match_criteria_test.go

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -400,17 +400,17 @@ func TestPrMatchesCriteria(t *testing.T) {
400400

401401
// Test cases
402402
tests := []struct {
403-
name string
404-
branch string
405-
prLabels []string
406-
combineBranch string
407-
ignoreLabelsVal []string
408-
selectLabelsVal []string
409-
caseSensitiveVal bool
410-
branchPrefixVal string
411-
branchSuffixVal string
412-
branchRegexVal string
413-
want bool
403+
name string
404+
branch string
405+
prLabels []string
406+
combineBranch string
407+
ignoreLabelsVal []string
408+
selectLabelsVal []string
409+
caseSensitiveVal bool
410+
branchPrefixVal string
411+
branchSuffixVal string
412+
branchRegexVal string
413+
want bool
414414
}{
415415
{
416416
name: "All criteria match",
@@ -504,19 +504,6 @@ func TestPrMatchesCriteria(t *testing.T) {
504504
}
505505
}
506506

507-
// Mock GraphQL client for testing
508-
type mockGraphQLClient struct {
509-
response interface{}
510-
err error
511-
}
512-
513-
func (m *mockGraphQLClient) Query(name string, query interface{}, variables map[string]interface{}) error {
514-
if m.err != nil {
515-
return m.err
516-
}
517-
return nil
518-
}
519-
520507
func TestIsCIPassing(t *testing.T) {
521508
tests := []struct {
522509
name string
@@ -1033,18 +1020,18 @@ func TestPrMeetsRequirements(t *testing.T) {
10331020
// Save original global variables
10341021
origRequireCI := requireCI
10351022
origMustBeApproved := mustBeApproved
1036-
1023+
10371024
// Restore original values after test
10381025
defer func() {
10391026
requireCI = origRequireCI
10401027
mustBeApproved = origMustBeApproved
10411028
}()
1042-
1029+
10431030
// Only test the simple case where no requirements are specified
10441031
t.Run("No requirements specified", func(t *testing.T) {
10451032
requireCI = false
10461033
mustBeApproved = false
1047-
1034+
10481035
// Skip this test since we can't easily create a mock graphql client
10491036
// The logic is simple enough that we know it would return true when both flags are false
10501037
t.Skip("Skipping test that requires a real GraphQL client")

internal/common/common_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ func TestNormalizeArray(t *testing.T) {
4646
}
4747
})
4848
}
49-
}
49+
}

internal/version/version_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,85 +11,85 @@ func TestString(t *testing.T) {
1111
origCommit := commit
1212
origDate := date
1313
origBuildInfoReader := buildInfoReader
14-
14+
1515
// Restore original values after the test
1616
defer func() {
1717
tag = origTag
1818
commit = origCommit
1919
date = origDate
2020
buildInfoReader = origBuildInfoReader
2121
}()
22-
22+
2323
// Test 1: With preset values (simulating ldflags setting)
2424
t.Run("with preset values", func(t *testing.T) {
2525
// Set known values for testing
2626
tag = "v1.0.0"
2727
commit = "abc123"
2828
date = "2025-04-15"
29-
29+
3030
// Mock the buildInfoReader to return false so that preset values are used
3131
buildInfoReader = func() (*debug.BuildInfo, bool) {
3232
return nil, false
3333
}
34-
34+
3535
result := String()
36-
36+
3737
// Test the full format
3838
expected := "v1.0.0 (abc123) built at 2025-04-15\nhttps://github.com/github/gh-combine/releases/tag/v1.0.0"
3939
if result != expected {
4040
t.Errorf("Expected version string to be:\n%q\nbut got:\n%q", expected, result)
4141
}
4242
})
43-
43+
4444
// Test 2: With mock build info that updates commit and date
4545
t.Run("with mock build info", func(t *testing.T) {
4646
// Set initial values
4747
tag = "dev"
4848
commit = "initial-commit"
4949
date = "initial-date"
50-
50+
5151
// Create mock build info with specific values
5252
mockSettings := []debug.BuildSetting{
5353
{Key: "vcs.revision", Value: "mock-commit-hash"},
5454
{Key: "vcs.time", Value: "mock-build-time"},
5555
{Key: "other.key", Value: "other-value"},
5656
}
57-
57+
5858
buildInfoReader = func() (*debug.BuildInfo, bool) {
5959
return &debug.BuildInfo{
6060
Settings: mockSettings,
6161
}, true
6262
}
63-
63+
6464
result := String()
65-
65+
6666
// Check if the values from build info were used
6767
expected := "dev (mock-commit-hash) built at mock-build-time\nhttps://github.com/github/gh-combine/releases/tag/dev"
6868
if result != expected {
6969
t.Errorf("Expected version string to be:\n%q\nbut got:\n%q", expected, result)
7070
}
7171
})
72-
72+
7373
// Test 3: With empty build info settings
7474
t.Run("with empty build info settings", func(t *testing.T) {
7575
// Set initial values
7676
tag = "dev"
7777
commit = "unchanged-commit"
7878
date = "unchanged-date"
79-
79+
8080
// Empty build settings
8181
buildInfoReader = func() (*debug.BuildInfo, bool) {
8282
return &debug.BuildInfo{
8383
Settings: []debug.BuildSetting{},
8484
}, true
8585
}
86-
86+
8787
result := String()
88-
88+
8989
// The values should remain unchanged
9090
expected := "dev (unchanged-commit) built at unchanged-date\nhttps://github.com/github/gh-combine/releases/tag/dev"
9191
if result != expected {
9292
t.Errorf("Expected version string to be:\n%q\nbut got:\n%q", expected, result)
9393
}
9494
})
95-
}
95+
}

0 commit comments

Comments
 (0)