-
Notifications
You must be signed in to change notification settings - Fork 48
Return a wrapped fs.ErrNotExist if no spec directories are defined #309
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -321,7 +321,7 @@ func (c *Cache) RemoveSpec(name string) error { | |
|
|
||
| specDir, _ = c.highestPrioritySpecDir() | ||
| if specDir == "" { | ||
| return errors.New("no Spec directories to remove from") | ||
| return fmt.Errorf("no Spec directories defined: %w", fs.ErrNotExist) | ||
|
Contributor
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. the fix looks good to me, but how about adding test case for this? err := cache.RemoveSpec("something")
assert.True(t, errors.Is(err, fs.ErrNotExist))
Contributor
Author
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. I have added a basic test.
Contributor
Author
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. @klihub as also pointed out by the test, we do have a slight disconnect here. In the case where the spec dirs are empty, we return
Contributor
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. @elezar Yes, probably would make sense. Returning
Contributor
Author
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. I think at this stage switching to returning Also, as a follow-up, does this mean that we should rather return
Contributor
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.
On the I think we still might get into the situation when there are no spec dirs, because someone might nuke them while we are running.
Contributor
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.
Yes, I also think we should try to be extra conservative even when it feels like PITA. We're post 1.0, so we should not be making breaking changes. Even if it's not immediately obvious why and how someone could rely on existing functionality so that it would break if we start returning ErrNotExists, it's better not to risk especially if there is not much to gain by the change. |
||
| } | ||
|
|
||
| path = filepath.Join(specDir, name) | ||
|
|
||
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.
@elezar Can this still happen with #310 merged ?
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.
It shouldn't be possible, no.
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.
Does that mean we want to update the
highestPrioritySpecDirimplementation to not return an error?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.
I think it does not return an error. It returns a directory and its priority.