fix: CI test failures and lint errors
- Fixed test file naming: issues.jsonl -> beads.jsonl - beads_test.go: Update expected path in TestFindJSONLPath - internal/beads/beads_test.go: Update TestFindJSONLPathDefault - cmd/bd/main_test.go: Update TestAutoFlushJSONLContent - Fixed lint errors (gosec): - G304: Added nosec comments for file operations with user-provided paths - G204: Added nosec comment for subprocess with controlled binary path - Fixed lint errors (errcheck): - cmd/bd/test_wait_helper.go: Acknowledge error return values with _ - cmd/bd/onboard.go: Handle fmt.Fprintf error return All tests passing locally. All lint checks passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -49,7 +49,7 @@ func TestFindJSONLPath(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jsonlPath := beads.FindJSONLPath(dbPath)
|
jsonlPath := beads.FindJSONLPath(dbPath)
|
||||||
expectedPath := filepath.Join(tmpDir, ".beads", "issues.jsonl")
|
expectedPath := filepath.Join(tmpDir, ".beads", "beads.jsonl")
|
||||||
|
|
||||||
if jsonlPath != expectedPath {
|
if jsonlPath != expectedPath {
|
||||||
t.Errorf("FindJSONLPath returned %s, expected %s", jsonlPath, expectedPath)
|
t.Errorf("FindJSONLPath returned %s, expected %s", jsonlPath, expectedPath)
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ func SyncBranchConfig(path string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set sync.branch using bd config set
|
// Set sync.branch using bd config set
|
||||||
|
// #nosec G204 - bdBinary is controlled by getBdBinary() which returns os.Executable()
|
||||||
setCmd := exec.Command(bdBinary, "config", "set", "sync.branch", currentBranch)
|
setCmd := exec.Command(bdBinary, "config", "set", "sync.branch", currentBranch)
|
||||||
setCmd.Dir = path
|
setCmd.Dir = path
|
||||||
if output, err := setCmd.CombinedOutput(); err != nil {
|
if output, err := setCmd.CombinedOutput(); err != nil {
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ func TestAutoFlushJSONLContent(t *testing.T) {
|
|||||||
dbPath = filepath.Join(tmpDir, "test.db")
|
dbPath = filepath.Join(tmpDir, "test.db")
|
||||||
// The actual JSONL path - findJSONLPath() will determine this
|
// The actual JSONL path - findJSONLPath() will determine this
|
||||||
// but in tests it appears to be issues.jsonl in the same directory as the db
|
// but in tests it appears to be issues.jsonl in the same directory as the db
|
||||||
expectedJSONLPath := filepath.Join(tmpDir, "issues.jsonl")
|
expectedJSONLPath := filepath.Join(tmpDir, "beads.jsonl")
|
||||||
|
|
||||||
// Create store
|
// Create store
|
||||||
testStore := newTestStore(t, dbPath)
|
testStore := newTestStore(t, dbPath)
|
||||||
|
|||||||
@@ -434,6 +434,7 @@ It is auto-generated and version-stamped to track bd upgrades.
|
|||||||
// generateBDGuide creates a version-stamped BD_GUIDE.md file
|
// generateBDGuide creates a version-stamped BD_GUIDE.md file
|
||||||
func generateBDGuide(outputPath string) error {
|
func generateBDGuide(outputPath string) error {
|
||||||
// Create output file
|
// Create output file
|
||||||
|
// #nosec G304 - outputPath is a user-provided flag value for file generation
|
||||||
f, err := os.Create(outputPath)
|
f, err := os.Create(outputPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create output file: %w", err)
|
return fmt.Errorf("failed to create output file: %w", err)
|
||||||
@@ -496,7 +497,7 @@ with bd upgrades) from project-specific instructions in AGENTS.md.`,
|
|||||||
if outputPath != "" {
|
if outputPath != "" {
|
||||||
// Generate BD_GUIDE.md instead of onboarding instructions
|
// Generate BD_GUIDE.md instead of onboarding instructions
|
||||||
if err := generateBDGuide(outputPath); err != nil {
|
if err := generateBDGuide(outputPath); err != nil {
|
||||||
fmt.Fprintf(cmd.ErrOrStderr(), "Error generating BD_GUIDE.md: %v\n", err)
|
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "Error generating BD_GUIDE.md: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
fmt.Printf("✓ Generated %s (bd v%s)\n", outputPath, Version)
|
fmt.Printf("✓ Generated %s (bd v%s)\n", outputPath, Version)
|
||||||
|
|||||||
@@ -39,27 +39,27 @@ func setupGitRepo(t *testing.T) (repoPath string, cleanup func()) {
|
|||||||
|
|
||||||
// Initialize git repo
|
// Initialize git repo
|
||||||
if err := exec.Command("git", "init").Run(); err != nil {
|
if err := exec.Command("git", "init").Run(); err != nil {
|
||||||
os.Chdir(originalWd)
|
_ = os.Chdir(originalWd)
|
||||||
t.Fatalf("failed to init git repo: %v", err)
|
t.Fatalf("failed to init git repo: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure git
|
// Configure git
|
||||||
exec.Command("git", "config", "user.email", "test@test.com").Run()
|
_ = exec.Command("git", "config", "user.email", "test@test.com").Run()
|
||||||
exec.Command("git", "config", "user.name", "Test User").Run()
|
_ = exec.Command("git", "config", "user.name", "Test User").Run()
|
||||||
|
|
||||||
// Create initial commit
|
// Create initial commit
|
||||||
if err := os.WriteFile("test.txt", []byte("test"), 0644); err != nil {
|
if err := os.WriteFile("test.txt", []byte("test"), 0600); err != nil {
|
||||||
os.Chdir(originalWd)
|
_ = os.Chdir(originalWd)
|
||||||
t.Fatalf("failed to write test file: %v", err)
|
t.Fatalf("failed to write test file: %v", err)
|
||||||
}
|
}
|
||||||
exec.Command("git", "add", "test.txt").Run()
|
_ = exec.Command("git", "add", "test.txt").Run()
|
||||||
if err := exec.Command("git", "commit", "-m", "initial").Run(); err != nil {
|
if err := exec.Command("git", "commit", "-m", "initial").Run(); err != nil {
|
||||||
os.Chdir(originalWd)
|
_ = os.Chdir(originalWd)
|
||||||
t.Fatalf("failed to create initial commit: %v", err)
|
t.Fatalf("failed to create initial commit: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup = func() {
|
cleanup = func() {
|
||||||
os.Chdir(originalWd)
|
_ = os.Chdir(originalWd)
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmpDir, cleanup
|
return tmpDir, cleanup
|
||||||
@@ -82,27 +82,27 @@ func setupGitRepoWithBranch(t *testing.T, branch string) (repoPath string, clean
|
|||||||
|
|
||||||
// Initialize git repo with specific branch
|
// Initialize git repo with specific branch
|
||||||
if err := exec.Command("git", "init", "-b", branch).Run(); err != nil {
|
if err := exec.Command("git", "init", "-b", branch).Run(); err != nil {
|
||||||
os.Chdir(originalWd)
|
_ = os.Chdir(originalWd)
|
||||||
t.Fatalf("failed to init git repo: %v", err)
|
t.Fatalf("failed to init git repo: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure git
|
// Configure git
|
||||||
exec.Command("git", "config", "user.email", "test@test.com").Run()
|
_ = exec.Command("git", "config", "user.email", "test@test.com").Run()
|
||||||
exec.Command("git", "config", "user.name", "Test User").Run()
|
_ = exec.Command("git", "config", "user.name", "Test User").Run()
|
||||||
|
|
||||||
// Create initial commit
|
// Create initial commit
|
||||||
if err := os.WriteFile("test.txt", []byte("test"), 0644); err != nil {
|
if err := os.WriteFile("test.txt", []byte("test"), 0600); err != nil {
|
||||||
os.Chdir(originalWd)
|
_ = os.Chdir(originalWd)
|
||||||
t.Fatalf("failed to write test file: %v", err)
|
t.Fatalf("failed to write test file: %v", err)
|
||||||
}
|
}
|
||||||
exec.Command("git", "add", "test.txt").Run()
|
_ = exec.Command("git", "add", "test.txt").Run()
|
||||||
if err := exec.Command("git", "commit", "-m", "initial").Run(); err != nil {
|
if err := exec.Command("git", "commit", "-m", "initial").Run(); err != nil {
|
||||||
os.Chdir(originalWd)
|
_ = os.Chdir(originalWd)
|
||||||
t.Fatalf("failed to create initial commit: %v", err)
|
t.Fatalf("failed to create initial commit: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup = func() {
|
cleanup = func() {
|
||||||
os.Chdir(originalWd)
|
_ = os.Chdir(originalWd)
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmpDir, cleanup
|
return tmpDir, cleanup
|
||||||
@@ -125,16 +125,16 @@ func setupMinimalGitRepo(t *testing.T) (repoPath string, cleanup func()) {
|
|||||||
|
|
||||||
// Initialize git repo
|
// Initialize git repo
|
||||||
if err := exec.Command("git", "init").Run(); err != nil {
|
if err := exec.Command("git", "init").Run(); err != nil {
|
||||||
os.Chdir(originalWd)
|
_ = os.Chdir(originalWd)
|
||||||
t.Fatalf("failed to init git repo: %v", err)
|
t.Fatalf("failed to init git repo: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure git
|
// Configure git
|
||||||
exec.Command("git", "config", "user.email", "test@test.com").Run()
|
_ = exec.Command("git", "config", "user.email", "test@test.com").Run()
|
||||||
exec.Command("git", "config", "user.name", "Test User").Run()
|
_ = exec.Command("git", "config", "user.name", "Test User").Run()
|
||||||
|
|
||||||
cleanup = func() {
|
cleanup = func() {
|
||||||
os.Chdir(originalWd)
|
_ = os.Chdir(originalWd)
|
||||||
}
|
}
|
||||||
|
|
||||||
return tmpDir, cleanup
|
return tmpDir, cleanup
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ func checkAndSuggestBDGuideUpdate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read first few lines to check version stamp
|
// Read first few lines to check version stamp
|
||||||
|
// #nosec G304 - guidePath is constructed from beadsDir + constant string
|
||||||
content, err := os.ReadFile(guidePath)
|
content, err := os.ReadFile(guidePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return // Silent failure
|
return // Silent failure
|
||||||
|
|||||||
@@ -168,9 +168,9 @@ func TestFindJSONLPathDefault(t *testing.T) {
|
|||||||
// Create a fake database path (no .jsonl files exist)
|
// Create a fake database path (no .jsonl files exist)
|
||||||
dbPath := filepath.Join(tmpDir, "test.db")
|
dbPath := filepath.Join(tmpDir, "test.db")
|
||||||
|
|
||||||
// Should return default issues.jsonl
|
// Should return default beads.jsonl
|
||||||
result := FindJSONLPath(dbPath)
|
result := FindJSONLPath(dbPath)
|
||||||
expected := filepath.Join(tmpDir, "issues.jsonl")
|
expected := filepath.Join(tmpDir, "beads.jsonl")
|
||||||
if result != expected {
|
if result != expected {
|
||||||
t.Errorf("Expected '%s', got '%s'", expected, result)
|
t.Errorf("Expected '%s', got '%s'", expected, result)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user