fix: all issues by golangci-lint
This commit is contained in:
@@ -12,15 +12,15 @@ import (
|
||||
func TestFileGenerator(t *testing.T) {
|
||||
// Setup mock files
|
||||
tmp := t.TempDir()
|
||||
os.MkdirAll(filepath.Join(tmp, "src"), 0755)
|
||||
os.WriteFile(filepath.Join(tmp, "main.go"), []byte(""), 0644)
|
||||
os.WriteFile(filepath.Join(tmp, "README.md"), []byte(""), 0644)
|
||||
os.WriteFile(filepath.Join(tmp, ".hidden"), []byte(""), 0644)
|
||||
os.WriteFile(filepath.Join(tmp, "src/utils.go"), []byte(""), 0644)
|
||||
_ = os.MkdirAll(filepath.Join(tmp, "src"), 0755)
|
||||
_ = os.WriteFile(filepath.Join(tmp, "main.go"), []byte(""), 0644)
|
||||
_ = os.WriteFile(filepath.Join(tmp, "README.md"), []byte(""), 0644)
|
||||
_ = os.WriteFile(filepath.Join(tmp, ".hidden"), []byte(""), 0644)
|
||||
_ = os.WriteFile(filepath.Join(tmp, "src/utils.go"), []byte(""), 0644)
|
||||
|
||||
oldWd, _ := os.Getwd()
|
||||
os.Chdir(tmp)
|
||||
defer os.Chdir(oldWd)
|
||||
_ = os.Chdir(tmp)
|
||||
defer func() { _ = os.Chdir(oldWd) }()
|
||||
|
||||
// REQUIREMENT: dirOnly shows only dirs
|
||||
t.Run("dirOnly shows only dirs", func(t *testing.T) {
|
||||
|
||||
@@ -16,12 +16,12 @@ func TestZoxideGenerator(t *testing.T) {
|
||||
|
||||
// Script that prints mock directories
|
||||
script := "#!/bin/sh\necho \"/home/verse/project1\n/home/verse/docs\n/home/verse/dev/iris\""
|
||||
os.WriteFile(mockZoxide, []byte(script), 0755)
|
||||
_ = os.WriteFile(mockZoxide, []byte(script), 0755)
|
||||
|
||||
// Add tmp to PATH
|
||||
oldPath := os.Getenv("PATH")
|
||||
os.Setenv("PATH", tmp+string(os.PathListSeparator)+oldPath)
|
||||
defer os.Setenv("PATH", oldPath)
|
||||
_ = os.Setenv("PATH", tmp+string(os.PathListSeparator)+oldPath)
|
||||
defer func() { _ = os.Setenv("PATH", oldPath) }()
|
||||
|
||||
gen := fs.ZoxideGenerator()
|
||||
|
||||
|
||||
@@ -14,22 +14,23 @@ func TestIntegration_ZoxideMultiWord(t *testing.T) {
|
||||
// Create mock directory with spaces
|
||||
tmp := t.TempDir()
|
||||
targetDir := filepath.Join(tmp, "My Awesome Project")
|
||||
os.MkdirAll(targetDir, 0755)
|
||||
_ = os.MkdirAll(targetDir, 0755)
|
||||
|
||||
// Mock shell environment
|
||||
oldWd, _ := os.Getwd()
|
||||
os.Chdir(tmp)
|
||||
defer os.Chdir(oldWd)
|
||||
_ = os.Chdir(tmp)
|
||||
defer func() { _ = os.Chdir(oldWd) }()
|
||||
|
||||
// Mock zoxide binary
|
||||
mockBinDir := t.TempDir()
|
||||
mockZoxide := filepath.Join(mockBinDir, "zoxide")
|
||||
// Create mock zoxide binary
|
||||
script := "#!/bin/sh\necho \"" + targetDir + "\""
|
||||
os.WriteFile(mockZoxide, []byte(script), 0755)
|
||||
|
||||
_ = os.WriteFile(mockZoxide, []byte(script), 0755)
|
||||
// Add mock bin to PATH
|
||||
oldPath := os.Getenv("PATH")
|
||||
os.Setenv("PATH", mockBinDir+string(os.PathListSeparator)+oldPath)
|
||||
defer os.Setenv("PATH", oldPath)
|
||||
_ = os.Setenv("PATH", mockBinDir+string(os.PathListSeparator)+oldPath)
|
||||
defer func() { _ = os.Setenv("PATH", oldPath) }()
|
||||
|
||||
t.Run("z matches multi-word folder without quotes", func(t *testing.T) {
|
||||
// Simulating user typing "z My Awe"
|
||||
|
||||
Reference in New Issue
Block a user