GithubHelp home page GithubHelp logo

Test coverage about go-guerrilla HOT 6 CLOSED

flashmob avatar flashmob commented on May 20, 2024
Test coverage

from go-guerrilla.

Comments (6)

flashmob avatar flashmob commented on May 20, 2024

Thanks, glad that it was useful!

The current tests are written using the go test way, no other conventions. Just add them .travis.yml 's "script:" section if you want them to run after each PR.

It would be good to write tests for the two bugs #44 and #42 so they won't happen again. So that would be the HELO/EHLO commands and DATA command.

So, to start you off - have a look at server_test.go (just committed). It has an example for how to mock net.Conn . (There are other tests such as tests/guerrilla_test.go which tests the server as a package and serve_test.go which test as a command line program where you may get examples form)

This issue also carries a bounty reward - so it would be wonderful to reward for the two cases (or maybe you can do more?)

from go-guerrilla.

brandonblock avatar brandonblock commented on May 20, 2024

Cool! I'll likely give it a peek this weekend.

from go-guerrilla.

brandonblock avatar brandonblock commented on May 20, 2024

@flashmob Hiya, so I've been working on this a little bit and noticed that the cmd handling logic isn't abstracted at all (so it's a little difficult to atomically test) – I'm wondering if abstracting that to a function would be out-of-bounds or welcome (so the PR would be an abstraction of that function and test cases for all the handled commands).

Also noticed that there's "coverage" on some functions in server.go from client_test.go but that there are uncaught errors in the tests. Is there a slack/irc channel for development that it would be good to ask specific questions about? Or are the issue threads the best place?

from go-guerrilla.

brandonblock avatar brandonblock commented on May 20, 2024

Oh, also the response types that are currently strings could be statically typed by net/http.Response.StatusCode* but I don't know if the project wants that dependency.

from go-guerrilla.

flashmob avatar flashmob commented on May 20, 2024

Hi, Brandon! @dapaxx has made some progress on the "enhanced status codes" SMTP extension - it has been merged to master recently. If you have a way to improve these - please let us know. Yes, using an int for the code is better than using a string.

The cmd handling logic was introduced by @remohammadi - maybe he already had solved the problem for how to test this individually, maybe he has some advice for us?
If you want to refactor - do you want to do something like this?: - http://stackoverflow.com/questions/35827147/cobra-viper-golang-how-to-test-subcommands

As for slack/irc, then the project may be too small for that - but asking in the issues is OK for now.

Finally, you're welcome to refactor something that makes something more testable, any day!

from go-guerrilla.

brandonblock avatar brandonblock commented on May 20, 2024

Looks like @dapaxx has done some great work on this front. I don't have as much free time right now as I was hoping so I'm going to contribute to coverage via unit tests for some of the abstract functions and dive deeper when I have the bandwidth.

from go-guerrilla.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.