Fix goconst linter warnings by converting repeated strings to constants

- Added testUserAlice constant for 'alice' in test files
- Added windowsOS constant for 'windows' in test files
- Added testIssueBD1/testIssueBD2 constants for 'bd-1'/'bd-2' in test files
- Added testVersion100 constant for '1.0.0' in version tests
- Added testIssueCustom1 constant for 'custom-1' in lazy init tests

Closes bd-54

Amp-Thread-ID: https://ampcode.com/threads/T-0a4e5d44-2d95-4948-8f4a-d8facf8657c7
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-10-25 13:33:51 -07:00
parent 94fb9fa531
commit 47c915ef10
10 changed files with 79 additions and 62 deletions

File diff suppressed because one or more lines are too long

View File

@@ -11,6 +11,8 @@ import (
"github.com/steveyegge/beads/internal/types" "github.com/steveyegge/beads/internal/types"
) )
const testUserAlice = "alice"
func TestCommentsCommand(t *testing.T) { func TestCommentsCommand(t *testing.T) {
tmpDir, err := os.MkdirTemp("", "bd-test-comments-*") tmpDir, err := os.MkdirTemp("", "bd-test-comments-*")
if err != nil { if err != nil {
@@ -41,7 +43,7 @@ func TestCommentsCommand(t *testing.T) {
} }
t.Run("add comment", func(t *testing.T) { t.Run("add comment", func(t *testing.T) {
comment, err := s.AddIssueComment(ctx, issue.ID, "alice", "This is a test comment") comment, err := s.AddIssueComment(ctx, issue.ID, testUserAlice, "This is a test comment")
if err != nil { if err != nil {
t.Fatalf("Failed to add comment: %v", err) t.Fatalf("Failed to add comment: %v", err)
} }
@@ -49,7 +51,7 @@ func TestCommentsCommand(t *testing.T) {
if comment.IssueID != issue.ID { if comment.IssueID != issue.ID {
t.Errorf("Expected issue ID %s, got %s", issue.ID, comment.IssueID) t.Errorf("Expected issue ID %s, got %s", issue.ID, comment.IssueID)
} }
if comment.Author != "alice" { if comment.Author != testUserAlice {
t.Errorf("Expected author alice, got %s", comment.Author) t.Errorf("Expected author alice, got %s", comment.Author)
} }
if comment.Text != "This is a test comment" { if comment.Text != "This is a test comment" {

View File

@@ -18,11 +18,13 @@ import (
"github.com/steveyegge/beads/internal/types" "github.com/steveyegge/beads/internal/types"
) )
const windowsOS = "windows"
func makeSocketTempDir(t testing.TB) string { func makeSocketTempDir(t testing.TB) string {
t.Helper() t.Helper()
base := "/tmp" base := "/tmp"
if runtime.GOOS == "windows" { if runtime.GOOS == windowsOS {
base = os.TempDir() base = os.TempDir()
} else if _, err := os.Stat(base); err != nil { } else if _, err := os.Stat(base); err != nil {
base = os.TempDir() base = os.TempDir()

View File

@@ -10,6 +10,11 @@ import (
"github.com/steveyegge/beads/internal/types" "github.com/steveyegge/beads/internal/types"
) )
const (
testIssueBD1 = "bd-1"
testIssueBD2 = "bd-2"
)
// TestRemapCollisionsRemapsImportedNotExisting verifies the bug fix where collision // TestRemapCollisionsRemapsImportedNotExisting verifies the bug fix where collision
// resolution incorrectly modified existing issue dependencies. // resolution incorrectly modified existing issue dependencies.
// //
@@ -38,7 +43,7 @@ func TestRemapCollisionsRemapsImportedNotExisting(t *testing.T) {
// Step 1: Create existing issues with dependencies // Step 1: Create existing issues with dependencies
existingIssues := []*types.Issue{ existingIssues := []*types.Issue{
{ {
ID: "bd-1", ID: testIssueBD1,
Title: "Existing BD-1", Title: "Existing BD-1",
Description: "Original database issue 1, depends on bd-2", Description: "Original database issue 1, depends on bd-2",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -46,7 +51,7 @@ func TestRemapCollisionsRemapsImportedNotExisting(t *testing.T) {
IssueType: types.TypeTask, IssueType: types.TypeTask,
}, },
{ {
ID: "bd-2", ID: testIssueBD2,
Title: "Existing BD-2", Title: "Existing BD-2",
Description: "Original database issue 2", Description: "Original database issue 2",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -56,7 +61,7 @@ func TestRemapCollisionsRemapsImportedNotExisting(t *testing.T) {
{ {
ID: "bd-3", ID: "bd-3",
Title: "Existing BD-3", Title: "Existing BD-3",
Description: "Original database issue 3, depends on bd-1", Description: "Original database issue 3, depends on " + testIssueBD1,
Status: types.StatusOpen, Status: types.StatusOpen,
Priority: 2, Priority: 2,
IssueType: types.TypeTask, IssueType: types.TypeTask,
@@ -71,13 +76,13 @@ func TestRemapCollisionsRemapsImportedNotExisting(t *testing.T) {
// Add dependencies between existing issues // Add dependencies between existing issues
dep1 := &types.Dependency{ dep1 := &types.Dependency{
IssueID: "bd-1", IssueID: testIssueBD1,
DependsOnID: "bd-2", DependsOnID: testIssueBD2,
Type: types.DepBlocks, Type: types.DepBlocks,
} }
dep2 := &types.Dependency{ dep2 := &types.Dependency{
IssueID: "bd-3", IssueID: "bd-3",
DependsOnID: "bd-1", DependsOnID: testIssueBD1,
Type: types.DepBlocks, Type: types.DepBlocks,
} }
if err := store.AddDependency(ctx, dep1, "test"); err != nil { if err := store.AddDependency(ctx, dep1, "test"); err != nil {
@@ -90,7 +95,7 @@ func TestRemapCollisionsRemapsImportedNotExisting(t *testing.T) {
// Step 2: Simulate importing issues with same IDs but different content // Step 2: Simulate importing issues with same IDs but different content
importedIssues := []*types.Issue{ importedIssues := []*types.Issue{
{ {
ID: "bd-1", ID: testIssueBD1,
Title: "Imported BD-1", Title: "Imported BD-1",
Description: "From import", Description: "From import",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -98,7 +103,7 @@ func TestRemapCollisionsRemapsImportedNotExisting(t *testing.T) {
IssueType: types.TypeTask, IssueType: types.TypeTask,
}, },
{ {
ID: "bd-2", ID: testIssueBD2,
Title: "Imported BD-2", Title: "Imported BD-2",
Description: "From import", Description: "From import",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -172,7 +177,7 @@ func TestRemapCollisionsRemapsImportedNotExisting(t *testing.T) {
t.Errorf("Expected 1 dependency for bd-3, got %d", len(existingDeps3)) t.Errorf("Expected 1 dependency for bd-3, got %d", len(existingDeps3))
} else { } else {
// Verify the dependency is correct // Verify the dependency is correct
if existingDeps3[0].DependsOnID != "bd-1" { if existingDeps3[0].DependsOnID != testIssueBD1 {
t.Errorf("Expected bd-3 → bd-1, got bd-3 → %s", existingDeps3[0].DependsOnID) t.Errorf("Expected bd-3 → bd-1, got bd-3 → %s", existingDeps3[0].DependsOnID)
} }
} }
@@ -206,7 +211,7 @@ func TestRemapCollisionsDoesNotUpdateNonexistentDependencies(t *testing.T) {
// Step 1: Create existing issue with dependency // Step 1: Create existing issue with dependency
existing1 := &types.Issue{ existing1 := &types.Issue{
ID: "bd-1", ID: testIssueBD1,
Title: "Existing BD-1", Title: "Existing BD-1",
Description: "Original database issue", Description: "Original database issue",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -214,7 +219,7 @@ func TestRemapCollisionsDoesNotUpdateNonexistentDependencies(t *testing.T) {
IssueType: types.TypeTask, IssueType: types.TypeTask,
} }
existing2 := &types.Issue{ existing2 := &types.Issue{
ID: "bd-2", ID: testIssueBD2,
Title: "Existing BD-2", Title: "Existing BD-2",
Description: "Original database issue", Description: "Original database issue",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -230,8 +235,8 @@ func TestRemapCollisionsDoesNotUpdateNonexistentDependencies(t *testing.T) {
// Add dependency between existing issues // Add dependency between existing issues
existingDep := &types.Dependency{ existingDep := &types.Dependency{
IssueID: "bd-1", IssueID: testIssueBD1,
DependsOnID: "bd-2", DependsOnID: testIssueBD2,
Type: types.DepBlocks, Type: types.DepBlocks,
} }
if err := store.AddDependency(ctx, existingDep, "test"); err != nil { if err := store.AddDependency(ctx, existingDep, "test"); err != nil {
@@ -241,7 +246,7 @@ func TestRemapCollisionsDoesNotUpdateNonexistentDependencies(t *testing.T) {
// Step 2: Import colliding issues (without dependencies in DB) // Step 2: Import colliding issues (without dependencies in DB)
imported := []*types.Issue{ imported := []*types.Issue{
{ {
ID: "bd-1", ID: testIssueBD1,
Title: "Imported BD-1", Title: "Imported BD-1",
Description: "From import, will be remapped", Description: "From import, will be remapped",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -276,7 +281,7 @@ func TestRemapCollisionsDoesNotUpdateNonexistentDependencies(t *testing.T) {
if len(existingDeps) != 1 { if len(existingDeps) != 1 {
t.Errorf("Expected 1 dependency for existing bd-1, got %d (dependency should not be touched)", len(existingDeps)) t.Errorf("Expected 1 dependency for existing bd-1, got %d (dependency should not be touched)", len(existingDeps))
} else { } else {
if existingDeps[0].DependsOnID != "bd-2" { if existingDeps[0].DependsOnID != testIssueBD2 {
t.Errorf("Expected bd-1 → bd-2, got bd-1 → %s", existingDeps[0].DependsOnID) t.Errorf("Expected bd-1 → bd-2, got bd-1 → %s", existingDeps[0].DependsOnID)
} }
} }

View File

@@ -40,7 +40,7 @@ func (h *listTestHelper) createTestIssues() {
Priority: 1, Priority: 1,
IssueType: types.TypeFeature, IssueType: types.TypeFeature,
Status: types.StatusInProgress, Status: types.StatusInProgress,
Assignee: "alice", Assignee: testUserAlice,
}, },
{ {
Title: "Task Issue", Title: "Task Issue",
@@ -128,10 +128,10 @@ func TestListCommand(t *testing.T) {
}) })
t.Run("filter by assignee", func(t *testing.T) { t.Run("filter by assignee", func(t *testing.T) {
assignee := "alice" assignee := testUserAlice
results := h.search(types.IssueFilter{Assignee: &assignee}) results := h.search(types.IssueFilter{Assignee: &assignee})
h.assertCount(len(results), 1, "issues for alice") h.assertCount(len(results), 1, "issues for alice")
h.assertEqual("alice", results[0].Assignee, "assignee") h.assertEqual(testUserAlice, results[0].Assignee, "assignee")
}) })
t.Run("filter by issue type", func(t *testing.T) { t.Run("filter by issue type", func(t *testing.T) {

View File

@@ -556,7 +556,7 @@ func TestAutoFlushJSONLContent(t *testing.T) {
// TestAutoFlushErrorHandling tests error scenarios in flush operations // TestAutoFlushErrorHandling tests error scenarios in flush operations
func TestAutoFlushErrorHandling(t *testing.T) { func TestAutoFlushErrorHandling(t *testing.T) {
if runtime.GOOS == "windows" { if runtime.GOOS == windowsOS {
t.Skip("chmod-based read-only directory behavior is not reliable on Windows") t.Skip("chmod-based read-only directory behavior is not reliable on Windows")
} }

View File

@@ -10,6 +10,8 @@ import (
sqlitestorage "github.com/steveyegge/beads/internal/storage/sqlite" sqlitestorage "github.com/steveyegge/beads/internal/storage/sqlite"
) )
const testVersion100 = "1.0.0"
func TestVersionCompatibility(t *testing.T) { func TestVersionCompatibility(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
@@ -20,8 +22,8 @@ func TestVersionCompatibility(t *testing.T) {
}{ }{
{ {
name: "Exact version match", name: "Exact version match",
serverVersion: "1.0.0", serverVersion: testVersion100,
clientVersion: "1.0.0", clientVersion: testVersion100,
shouldWork: true, shouldWork: true,
}, },
{ {
@@ -39,7 +41,7 @@ func TestVersionCompatibility(t *testing.T) {
}, },
{ {
name: "Different major versions - client newer", name: "Different major versions - client newer",
serverVersion: "1.0.0", serverVersion: testVersion100,
clientVersion: "2.0.0", clientVersion: "2.0.0",
shouldWork: false, shouldWork: false,
errorContains: "incompatible major versions", errorContains: "incompatible major versions",
@@ -47,13 +49,13 @@ func TestVersionCompatibility(t *testing.T) {
{ {
name: "Different major versions - daemon newer", name: "Different major versions - daemon newer",
serverVersion: "2.0.0", serverVersion: "2.0.0",
clientVersion: "1.0.0", clientVersion: testVersion100,
shouldWork: false, shouldWork: false,
errorContains: "incompatible major versions", errorContains: "incompatible major versions",
}, },
{ {
name: "Empty client version (legacy client)", name: "Empty client version (legacy client)",
serverVersion: "1.0.0", serverVersion: testVersion100,
clientVersion: "", clientVersion: "",
shouldWork: true, shouldWork: true,
}, },
@@ -65,8 +67,8 @@ func TestVersionCompatibility(t *testing.T) {
}, },
{ {
name: "Version without v prefix", name: "Version without v prefix",
serverVersion: "1.0.0", serverVersion: testVersion100,
clientVersion: "1.0.0", clientVersion: testVersion100,
shouldWork: true, shouldWork: true,
}, },
{ {
@@ -182,8 +184,8 @@ func TestHealthCheckIncludesVersionInfo(t *testing.T) {
defer store.Close() defer store.Close()
// Set explicit versions // Set explicit versions
ServerVersion = "1.0.0" ServerVersion = testVersion100
ClientVersion = "1.0.0" ClientVersion = testVersion100
server := NewServer(socketPath, store) server := NewServer(socketPath, store)
@@ -246,7 +248,7 @@ func TestIncompatibleVersionInHealth(t *testing.T) {
defer store.Close() defer store.Close()
// Set incompatible versions // Set incompatible versions
ServerVersion = "1.0.0" ServerVersion = testVersion100
ClientVersion = "2.0.0" ClientVersion = "2.0.0"
server := NewServer(socketPath, store) server := NewServer(socketPath, store)
@@ -304,7 +306,7 @@ func TestVersionCheckMessage(t *testing.T) {
}{ }{
{ {
name: "Major mismatch - daemon older", name: "Major mismatch - daemon older",
serverVersion: "1.0.0", serverVersion: testVersion100,
clientVersion: "2.0.0", clientVersion: "2.0.0",
expectError: true, expectError: true,
errorContains: "Daemon is older; upgrade and restart daemon", errorContains: "Daemon is older; upgrade and restart daemon",
@@ -312,13 +314,13 @@ func TestVersionCheckMessage(t *testing.T) {
{ {
name: "Major mismatch - client older", name: "Major mismatch - client older",
serverVersion: "2.0.0", serverVersion: "2.0.0",
clientVersion: "1.0.0", clientVersion: testVersion100,
expectError: true, expectError: true,
errorContains: "Client is older; upgrade the bd CLI", errorContains: "Client is older; upgrade the bd CLI",
}, },
{ {
name: "Minor mismatch - daemon older", name: "Minor mismatch - daemon older",
serverVersion: "1.0.0", serverVersion: testVersion100,
clientVersion: "1.1.0", clientVersion: "1.1.0",
expectError: true, expectError: true,
errorContains: "daemon 1.0.0 is older than client 1.1.0", errorContains: "daemon 1.0.0 is older than client 1.1.0",
@@ -326,7 +328,7 @@ func TestVersionCheckMessage(t *testing.T) {
{ {
name: "Compatible versions", name: "Compatible versions",
serverVersion: "1.1.0", serverVersion: "1.1.0",
clientVersion: "1.0.0", clientVersion: testVersion100,
expectError: false, expectError: false,
}, },
} }
@@ -366,7 +368,7 @@ func TestPingAndHealthBypassVersionCheck(t *testing.T) {
defer store.Close() defer store.Close()
// Set incompatible versions // Set incompatible versions
ServerVersion = "1.0.0" ServerVersion = testVersion100
ClientVersion = "2.0.0" ClientVersion = "2.0.0"
server := NewServer(socketPath, store) server := NewServer(socketPath, store)
@@ -440,8 +442,8 @@ func TestMetricsOperation(t *testing.T) {
} }
defer store.Close() defer store.Close()
ServerVersion = "1.0.0" ServerVersion = testVersion100
ClientVersion = "1.0.0" ClientVersion = testVersion100
server := NewServer(socketPath, store) server := NewServer(socketPath, store)

View File

@@ -10,6 +10,8 @@ import (
"github.com/steveyegge/beads/internal/types" "github.com/steveyegge/beads/internal/types"
) )
const testIssueBD1 = "bd-1"
func TestDetectCollisions(t *testing.T) { func TestDetectCollisions(t *testing.T) {
// Create temporary database // Create temporary database
tmpDir, err := os.MkdirTemp("", "collision-test-*") tmpDir, err := os.MkdirTemp("", "collision-test-*")
@@ -29,7 +31,7 @@ func TestDetectCollisions(t *testing.T) {
// Setup: Create some existing issues in the database // Setup: Create some existing issues in the database
existingIssue1 := &types.Issue{ existingIssue1 := &types.Issue{
ID: "bd-1", ID: testIssueBD1,
Title: "Existing issue 1", Title: "Existing issue 1",
Description: "This is an existing issue", Description: "This is an existing issue",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -66,7 +68,7 @@ func TestDetectCollisions(t *testing.T) {
name: "exact match - idempotent import", name: "exact match - idempotent import",
incomingIssues: []*types.Issue{ incomingIssues: []*types.Issue{
{ {
ID: "bd-1", ID: testIssueBD1,
Title: "Existing issue 1", Title: "Existing issue 1",
Description: "This is an existing issue", Description: "This is an existing issue",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -98,7 +100,7 @@ func TestDetectCollisions(t *testing.T) {
name: "collision - same ID, different title", name: "collision - same ID, different title",
incomingIssues: []*types.Issue{ incomingIssues: []*types.Issue{
{ {
ID: "bd-1", ID: testIssueBD1,
Title: "Modified title", Title: "Modified title",
Description: "This is an existing issue", Description: "This is an existing issue",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -113,7 +115,7 @@ func TestDetectCollisions(t *testing.T) {
if len(collisions) != 1 { if len(collisions) != 1 {
t.Fatalf("expected 1 collision, got %d", len(collisions)) t.Fatalf("expected 1 collision, got %d", len(collisions))
} }
if collisions[0].ID != "bd-1" { if collisions[0].ID != testIssueBD1 {
t.Errorf("expected collision ID bd-1, got %s", collisions[0].ID) t.Errorf("expected collision ID bd-1, got %s", collisions[0].ID)
} }
if len(collisions[0].ConflictingFields) != 1 { if len(collisions[0].ConflictingFields) != 1 {
@@ -167,7 +169,7 @@ func TestDetectCollisions(t *testing.T) {
incomingIssues: []*types.Issue{ incomingIssues: []*types.Issue{
{ {
// Exact match // Exact match
ID: "bd-1", ID: testIssueBD1,
Title: "Existing issue 1", Title: "Existing issue 1",
Description: "This is an existing issue", Description: "This is an existing issue",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -201,7 +203,7 @@ func TestDetectCollisions(t *testing.T) {
name: "collision - estimated_minutes differs", name: "collision - estimated_minutes differs",
incomingIssues: []*types.Issue{ incomingIssues: []*types.Issue{
{ {
ID: "bd-1", ID: testIssueBD1,
Title: "Existing issue 1", Title: "Existing issue 1",
Description: "This is an existing issue", Description: "This is an existing issue",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -258,7 +260,7 @@ func TestCompareIssues(t *testing.T) {
{ {
name: "identical issues", name: "identical issues",
existing: &types.Issue{ existing: &types.Issue{
ID: "bd-1", ID: testIssueBD1,
Title: "Test", Title: "Test",
Description: "Test desc", Description: "Test desc",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -266,7 +268,7 @@ func TestCompareIssues(t *testing.T) {
IssueType: types.TypeTask, IssueType: types.TypeTask,
}, },
incoming: &types.Issue{ incoming: &types.Issue{
ID: "bd-1", ID: testIssueBD1,
Title: "Test", Title: "Test",
Description: "Test desc", Description: "Test desc",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -278,7 +280,7 @@ func TestCompareIssues(t *testing.T) {
{ {
name: "different title", name: "different title",
existing: &types.Issue{ existing: &types.Issue{
ID: "bd-1", ID: testIssueBD1,
Title: "Original", Title: "Original",
Description: "Test", Description: "Test",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -286,7 +288,7 @@ func TestCompareIssues(t *testing.T) {
IssueType: types.TypeTask, IssueType: types.TypeTask,
}, },
incoming: &types.Issue{ incoming: &types.Issue{
ID: "bd-1", ID: testIssueBD1,
Title: "Modified", Title: "Modified",
Description: "Test", Description: "Test",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -298,7 +300,7 @@ func TestCompareIssues(t *testing.T) {
{ {
name: "different status and priority", name: "different status and priority",
existing: &types.Issue{ existing: &types.Issue{
ID: "bd-1", ID: testIssueBD1,
Title: "Test", Title: "Test",
Description: "Test", Description: "Test",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -306,7 +308,7 @@ func TestCompareIssues(t *testing.T) {
IssueType: types.TypeTask, IssueType: types.TypeTask,
}, },
incoming: &types.Issue{ incoming: &types.Issue{
ID: "bd-1", ID: testIssueBD1,
Title: "Test", Title: "Test",
Description: "Test", Description: "Test",
Status: types.StatusClosed, Status: types.StatusClosed,
@@ -318,7 +320,7 @@ func TestCompareIssues(t *testing.T) {
{ {
name: "estimated_minutes - both nil", name: "estimated_minutes - both nil",
existing: &types.Issue{ existing: &types.Issue{
ID: "bd-1", ID: testIssueBD1,
Title: "Test", Title: "Test",
Description: "Test", Description: "Test",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -327,7 +329,7 @@ func TestCompareIssues(t *testing.T) {
EstimatedMinutes: nil, EstimatedMinutes: nil,
}, },
incoming: &types.Issue{ incoming: &types.Issue{
ID: "bd-1", ID: testIssueBD1,
Title: "Test", Title: "Test",
Description: "Test", Description: "Test",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -340,7 +342,7 @@ func TestCompareIssues(t *testing.T) {
{ {
name: "estimated_minutes - existing nil, incoming set", name: "estimated_minutes - existing nil, incoming set",
existing: &types.Issue{ existing: &types.Issue{
ID: "bd-1", ID: testIssueBD1,
Title: "Test", Title: "Test",
Description: "Test", Description: "Test",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -349,7 +351,7 @@ func TestCompareIssues(t *testing.T) {
EstimatedMinutes: nil, EstimatedMinutes: nil,
}, },
incoming: &types.Issue{ incoming: &types.Issue{
ID: "bd-1", ID: testIssueBD1,
Title: "Test", Title: "Test",
Description: "Test", Description: "Test",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -362,7 +364,7 @@ func TestCompareIssues(t *testing.T) {
{ {
name: "estimated_minutes - same values", name: "estimated_minutes - same values",
existing: &types.Issue{ existing: &types.Issue{
ID: "bd-1", ID: testIssueBD1,
Title: "Test", Title: "Test",
Description: "Test", Description: "Test",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -371,7 +373,7 @@ func TestCompareIssues(t *testing.T) {
EstimatedMinutes: intPtr(60), EstimatedMinutes: intPtr(60),
}, },
incoming: &types.Issue{ incoming: &types.Issue{
ID: "bd-1", ID: testIssueBD1,
Title: "Test", Title: "Test",
Description: "Test", Description: "Test",
Status: types.StatusOpen, Status: types.StatusOpen,
@@ -710,7 +712,7 @@ func TestCountReferencesWordBoundary(t *testing.T) {
// Adjust expected based on actual counting logic // Adjust expected based on actual counting logic
// countReferences skips the issue itself // countReferences skips the issue itself
expected := tt.expectedCount expected := tt.expectedCount
if tt.issueID == "bd-1" { if tt.issueID == testIssueBD1 {
expected = 1 // only bd-10's description expected = 1 // only bd-10's description
} }

View File

@@ -7,6 +7,8 @@ import (
"github.com/steveyegge/beads/internal/types" "github.com/steveyegge/beads/internal/types"
) )
const testUserAlice = "alice"
func TestAddComment(t *testing.T) { func TestAddComment(t *testing.T) {
store, cleanup := setupTestDB(t) store, cleanup := setupTestDB(t)
defer cleanup() defer cleanup()
@@ -26,7 +28,7 @@ func TestAddComment(t *testing.T) {
} }
// Add a comment // Add a comment
err = store.AddComment(ctx, issue.ID, "alice", "This is a test comment") err = store.AddComment(ctx, issue.ID, testUserAlice, "This is a test comment")
if err != nil { if err != nil {
t.Fatalf("AddComment failed: %v", err) t.Fatalf("AddComment failed: %v", err)
} }
@@ -55,7 +57,7 @@ func TestAddComment(t *testing.T) {
t.Fatal("Comment event not found") t.Fatal("Comment event not found")
} }
if commentEvent.Actor != "alice" { if commentEvent.Actor != testUserAlice {
t.Errorf("Expected actor 'alice', got '%s'", commentEvent.Actor) t.Errorf("Expected actor 'alice', got '%s'", commentEvent.Actor)
} }

View File

@@ -9,6 +9,8 @@ import (
"github.com/steveyegge/beads/internal/types" "github.com/steveyegge/beads/internal/types"
) )
const testIssueCustom1 = "custom-1"
// TestLazyCounterInitialization verifies that counters are initialized lazily // TestLazyCounterInitialization verifies that counters are initialized lazily
// on first use, not by scanning the entire database on every CreateIssue // on first use, not by scanning the entire database on every CreateIssue
func TestLazyCounterInitialization(t *testing.T) { func TestLazyCounterInitialization(t *testing.T) {
@@ -163,7 +165,7 @@ func TestLazyCounterInitializationMultiplePrefix(t *testing.T) {
t.Fatalf("CreateIssue failed: %v", err) t.Fatalf("CreateIssue failed: %v", err)
} }
if customIssue.ID != "custom-1" { if customIssue.ID != testIssueCustom1 {
t.Errorf("Expected custom-1, got %s", customIssue.ID) t.Errorf("Expected custom-1, got %s", customIssue.ID)
} }