-
-
Notifications
You must be signed in to change notification settings - Fork 414
feat: Zoxide tests #1042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: Zoxide tests #1042
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ import ( | |
| "reflect" | ||
| "runtime" | ||
|
|
||
| "github.com/lazysegtree/go-zoxide" | ||
| zoxidelib "github.com/lazysegtree/go-zoxide" | ||
|
|
||
| "github.com/yorukot/superfile/src/internal/ui/processbar" | ||
| "github.com/yorukot/superfile/src/internal/ui/rendering" | ||
|
|
@@ -25,7 +25,7 @@ import ( | |
|
|
||
| // This is the only usecase of named returns, distinguish between multiple return values | ||
| func initialConfig(firstFilePanelDirs []string) (toggleDotFile bool, //nolint: nonamedreturns // See above | ||
| toggleFooter bool, zClient *zoxide.Client) { | ||
| toggleFooter bool, zClient *zoxidelib.Client) { | ||
| // Open log stream | ||
| file, err := os.OpenFile(variable.LogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) | ||
|
|
||
|
|
@@ -73,7 +73,7 @@ func initialConfig(firstFilePanelDirs []string) (toggleDotFile bool, //nolint: n | |
| } | ||
|
|
||
| if common.Config.ZoxideSupport { | ||
| zClient, err = zoxide.New() | ||
| zClient, err = zoxidelib.New() | ||
| if err != nil { | ||
| slog.Error("Error initializing zoxide client", "error", err) | ||
| } | ||
|
|
@@ -90,27 +90,31 @@ func initialConfig(firstFilePanelDirs []string) (toggleDotFile bool, //nolint: n | |
| return toggleDotFile, toggleFooter, zClient | ||
| } | ||
|
|
||
| func updateFirstFilePanelDirs(firstFilePanelDirs []string, cwd string, zClient *zoxide.Client) { | ||
| func updateFirstFilePanelDirs(firstFilePanelDirs []string, cwd string, zClient *zoxidelib.Client) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ New issue: Deep, Nested Complexity |
||
| for i := range firstFilePanelDirs { | ||
| if firstFilePanelDirs[i] == "" { | ||
| firstFilePanelDirs[i] = common.Config.DefaultDirectory | ||
| } | ||
| originalPath := firstFilePanelDirs[i] | ||
| firstFilePanelDirs[i] = utils.ResolveAbsPath(cwd, firstFilePanelDirs[i]) | ||
|
|
||
| if common.Config.ZoxideSupport && zClient != nil { | ||
| path, err := zClient.Query(firstFilePanelDirs[i]) | ||
| if err == nil && path != "" { | ||
| firstFilePanelDirs[i] = path | ||
| } else { | ||
| slog.Error("Zoxide execution error", "path", path, "error", err) | ||
| firstFilePanelDirs[i] = utils.ResolveAbsPath(cwd, firstFilePanelDirs[i]) | ||
| } | ||
| } else { | ||
| firstFilePanelDirs[i] = utils.ResolveAbsPath(cwd, firstFilePanelDirs[i]) | ||
| } | ||
| // In case of unexpected path error, fallback to home dir | ||
| if _, err := os.Stat(firstFilePanelDirs[i]); err != nil { | ||
| slog.Error("cannot get stats for firstFilePanelDir", "error", err) | ||
| firstFilePanelDirs[i] = variable.HomeDir | ||
| // In case the path provided did not exist, use zoxide query | ||
| // else, fallback to home dir | ||
| if common.Config.ZoxideSupport && zClient != nil { | ||
| path, err := zClient.Query(originalPath) | ||
| slog.Error("Zoxide execution error", "path", path, "originalPath", originalPath, "error", err) | ||
|
|
||
| if err == nil && path != "" { | ||
| firstFilePanelDirs[i] = path | ||
| } else { | ||
| slog.Error("Zoxide execution error", "path", path, "originalPath", originalPath, "error", err) | ||
| firstFilePanelDirs[i] = variable.HomeDir | ||
| } | ||
| } else { | ||
| firstFilePanelDirs[i] = variable.HomeDir | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai
Do a strict review for this PR
Check if any refactoring is breaking existing behaviour.
Check if any manual testing or unit testing is must have to ensure no regressions.
Check for any bugs, over-engineering or changes that will reduce code readability/maintainability in the long term
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 16294
🏁 Script executed:
Length of output: 2946
@lazysegtree
After conducting a thorough strict review of PR #1042, here's my comprehensive analysis:
✅ Overall Assessment: This is a well-executed refactoring with significant improvements
Changes Analysis:
Import Consistency Fix ✅
zoxidelibalias consistent across all filesconfig_function.gowas the only file using barezoxideimportComprehensive Test Coverage Addition ✅
Bug Fix ✅
m.Close()call after zoxide modal confirmationTesting Infrastructure ✅
defaultTestModelWithZClient()helper functionGetResults()method for test verificationNo Regressions Identified:
Recommended Testing:
While the code changes are safe, manual testing would be valuable to verify:
Code Quality:
Verdict: This PR improves code consistency, adds missing test coverage, and fixes an actual bug. No breaking changes or regressions identified.
🧠 Learnings used