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

Mocking Torrent internals #53

Closed
zhulik opened this issue Dec 26, 2015 · 5 comments
Closed

Mocking Torrent internals #53

zhulik opened this issue Dec 26, 2015 · 5 comments

Comments

@zhulik
Copy link
Contributor

zhulik commented Dec 26, 2015

Hi. I writing tests for my downloader and i don't want to download anything there. So, i ran into troubles with mocking Torrent.

You define Torrent struct as

type Torrent struct {
    cl *Client
    *torrent
}

I undestand, that you want to encapsulate it's logic from the outside code. But it creates some barrier for changing it's internals from the client tests. Your tests is defined in the same package as library, so you can do anything in tests. It is impossible to do it from my tests.

The good practice for testing libraries is defining it's tests in separate package torrent_test for example.

Is there any way(interfaces magic or something else) to totally mock downloading and write tests without network access?

@anacrolix
Copy link
Owner

I don't have much experience with mocking, so I'm open to suggestions. If you can provide mocks to be included with the torrent repo I would be appreciative. Open any PR you need to make this happen.

@zhulik
Copy link
Contributor Author

zhulik commented Jan 8, 2016

Sorry for my PR, i add some abstraction layer in my and it allows me to mock torrent package without changing it.

@zhulik zhulik closed this as completed Jan 8, 2016
@anacrolix
Copy link
Owner

Great to see you solved it. If any of the mocked tests can be submitted that would be useful.

@zhulik
Copy link
Contributor Author

zhulik commented Jan 8, 2016

Now i have some expirience with torrent package, so, i will add some readme and examples in a few days.

@anacrolix
Copy link
Owner

Cheers

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

No branches or pull requests

2 participants