/lclhst

Wait for localhost to be ready like what?!?!

Primary LanguageGoMIT LicenseMIT

lclhst

Build Status godoc

Wait for localhost to be ready like what?!?!

Wait for localhost to be ready in order to run tests or anything that relies on localhost responding.

Installation:

Install the library:

go get github.com/m90/lclhst

Install the command:

go get github.com/m90/lclhst/cmd/lclhst

Usage

In integration tests for servers, use Wait before running the tests for func main:

func TestMain(m *testing.M) {
    go main()
    lclhst.Wait(8080)
    os.Exit(m.Run())
}

Use the command before running anything that expects localhost to be up:

lclhst && curl localhost:8080

The following options are available:

Usage of lclhst:
  -port int
    	the port of the application (default 8080)
  -timeout duration
    	timeout for giving up (default 10s)

License

MIT © Frederik Ring