2017-10-12 15:25:00 +02:00
|
|
|
package webserver
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestWebserver(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
2018-01-13 14:13:44 +01:00
|
|
|
srv := New(":12345", "/tmp")
|
2017-10-12 15:25:00 +02:00
|
|
|
assert.NotNil(srv)
|
|
|
|
|
|
|
|
go Start(srv)
|
|
|
|
|
|
|
|
time.Sleep(time.Millisecond * 200)
|
|
|
|
|
|
|
|
assert.Panics(func() {
|
|
|
|
Start(srv)
|
|
|
|
}, "not allowed to listen twice")
|
|
|
|
|
|
|
|
srv.Close()
|
|
|
|
}
|