-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Added tests for utils/svn #2950
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
13fb14a
Added tests fir utils/svn
mansimarkaur cf96d8d
Improved tests for svn_available?
mansimarkaur 53be6bb
Added check for svn availability
mansimarkaur d9c0b8c
Added clear_svn_version_cache
mansimarkaur d533973
Used clear_svn_version_cache to remove @svn
mansimarkaur 3d8873c
url skipped if svn not available when auditing urls
mansimarkaur 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| require "utils/svn" | ||
|
|
||
| describe Utils do | ||
| describe "#self.svn_available?" do | ||
| before(:each) do | ||
| described_class.clear_svn_version_cache | ||
| end | ||
|
|
||
| it "returns svn version if svn available" do | ||
| expect(described_class.svn_available?).to be_truthy | ||
| end | ||
| end | ||
|
|
||
| describe "#self.svn_remote_exists" do | ||
| it "returns true when svn is not available" do | ||
| allow(Utils).to receive(:svn_available?).and_return(false) | ||
| expect(described_class.svn_remote_exists("blah")).to be_truthy | ||
| end | ||
|
|
||
| context "when svn is available" do | ||
| before do | ||
| allow(Utils).to receive(:svn_available?).and_return(true) | ||
| end | ||
|
|
||
| it "returns false when remote does not exist" do | ||
| expect(described_class.svn_remote_exists(HOMEBREW_CACHE/"install")).to be_falsey | ||
| end | ||
|
|
||
| it "returns true when remote exists", :needs_network do | ||
| remote = "http://github.com/Homebrew/install" | ||
| svn = HOMEBREW_SHIMS_PATH/"scm/svn" | ||
|
|
||
| HOMEBREW_CACHE.cd { system svn, "checkout", remote } | ||
|
|
||
| expect(described_class.svn_remote_exists(HOMEBREW_CACHE/"install")).to be_truthy | ||
| end | ||
| end | ||
| end | ||
| end |
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
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.
This is never needed, except in tests, so this shouldn‘t exist in the actual code.
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.
@reitermarkus I'm not sure how this gets resolved without adding a method here. What would you propose?
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.
How about adding a method in one of the support modules for tests to clear any instance variable? As in a method whose argument is the instance variable to be cleared. @MikeMcQuaid @reitermarkus @mistydemeo
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.
@mansimarkaur If by support modules you mean in the
spec_helperor something then: yeh, that could work. @reitermarkus?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.
Also, there's probably some times this method should be called anyway such as e.g. after a new installation of
svn(and same thing forgit)Uh oh!
There was an error while loading. Please reload this page.
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.
@MikeMcQuaid Yes, I meant adding a method in the
spec_helperbut if we want to call this cache clear method after a new installation, then we don't need to add it in thespec_helper. Which is a better alternative? Also,utils/git.rbalready has aUtils.clear_git_available_cacheto remove@git,@git_pathand@git_version: https://github.com/Homebrew/brew/blob/master/Library/Homebrew/utils/git.rb#L66There 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.
@mansimarkaur I think this is fine as-is, then, thanks.