Hello! Glad you've come. This week, I've been working on some Go unit testing, but this time not for SSGo, but rather for a project called chunk. Let me tell you more, maybe you'll gain something valuable for yourself!
Project overview
Chunk is a download manager that downloads packages from a given URL divided in chunks one by one. It is written in Go and it is a starter project.
Unit testing target and tools I used
Before chunk can download something, it needs to know it's size, and I have been working on unit testing getDownloadSize()
function. It fetches a given URL and checks for its ContentLength or Content-Range header for understanding the size of the download. In the repo, there was an issue regarding that, so I made sure to let the maintainers know that I would like to work on the issue.
Since the project had tests in vanilla Go, I didn't use any additional packages like testify
to keep the style consistent. It is important not to make a mess out in code, so new contributors understand the coding style of the project.
Communication is key
Sometimes, you'll not get the full understanding of an issue, and get some feedback on your work. This does not necessarily mean you did wrong, and even if you did, it's obviously not the end of the world. It is important to hear what project maintainers have to say about your changes in order to make a useful contribution.
When I did my initial commit, I did get some feedback on what should be changed. It also involved some non-testing code changes, and I fell like my eventual changes would bring some better usability because I made actual code just a bit better.
In the end, my pull request has been approved and merged, and another successful contribution has been made. It's just incredible to contribute to other projects, having to also learn something new in the process.
Top comments (0)