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

test case added for listenAndServe #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ go:
- 1.9
- tip

before_script:
- openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem -subj '/CN=localhost'

script:
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls
Expand Down
22 changes: 22 additions & 0 deletions engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io/ioutil"

"github.com/stretchr/testify/assert"
"time"
)

type errorTester struct{}
Expand Down Expand Up @@ -109,3 +110,24 @@ func TestEngineFileServe(t *testing.T) {
assert.Equal(t, http.StatusNotFound, resp3.Code)

}

func TestEngineListenAndServe(t *testing.T) {
e := newEngineTest()
var err error
var errTLS error

go func () {
err = e.ListenAndServe(":1234")
}()

go func() {
errTLS = e.ListenAndServeTLS(":12345", "cert.pem", "key.pem")
}()


// wait for ListenAndServe to run
time.Sleep(time.Millisecond * 300)

assert.NoError(t, err)
assert.NoError(t, errTLS)
}