Skip to content
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

Tests for mfsr.go #3618

Merged
merged 4 commits into from
Mar 2, 2017
Merged

Tests for mfsr.go #3618

merged 4 commits into from
Mar 2, 2017

Conversation

zmackie
Copy link
Contributor

@zmackie zmackie commented Jan 20, 2017

Adds tests for msfr.go. Does not hit coverage target of 80%.
Remove code that was transforming errs when the version file didn't exist, which may have confused callers of the Version method.

@@ -23,8 +23,8 @@ func (rp RepoPath) Version() (int, error) {
}

fn := rp.VersionFile()
if _, err := os.Stat(fn); os.IsNotExist(err) {
return 0, VersionFileNotFound(rp)
if _, err := os.Stat(fn); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this because I noticed that the only caller of the method (https://github.com/Zanadar/go-ipfs/blob/77e46b40b1ec1e7799915c6dd1a4a38e9d741622/repo/fsrepo/fsrepo.go#L142) explicitly checks for os.IsNotExist(err) and when we transform the error here, that check in the caller never returns true.

On second consideration, it may be better to check in the caller for err == VersionFileNotFound as this error gives a little more context.

Hope that clarifies.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that makes sense then.

@whyrusleeping
Copy link
Member

@Zanadar do you mind rebasing this PR on latest master? To get CI on jenkins running properly we need the new makefile changes

License: MIT
Signed-off-by: Zander Mackie <zmackie@gmail.com>
- fsrepo calls and checks for this error (`fsrepo.go:140`)

License: MIT
Signed-off-by: Zander Mackie <zmackie@gmail.com>
License: MIT
Signed-off-by: Zander Mackie <zmackie@gmail.com>
License: MIT
Signed-off-by: Zander Mackie <zmackie@gmail.com>
@zmackie
Copy link
Contributor Author

zmackie commented Feb 13, 2017

Rebased.

Copy link
Member

@whyrusleeping whyrusleeping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @Zanadar !

@whyrusleeping whyrusleeping merged commit 473f875 into ipfs:master Mar 2, 2017
@whyrusleeping whyrusleeping added this to the Ipfs 0.4.7 milestone Mar 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants