yanic/webserver/webserver_test.go

31 lines
400 B
Go
Raw Permalink Normal View History

package webserver
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestWebserver(t *testing.T) {
assert := assert.New(t)
2024-07-05 02:08:54 +02:00
config := Config{
Bind: ":12345",
Webroot: "/tmp",
}
srv := New(config, nil)
assert.NotNil(srv)
go Start(srv)
time.Sleep(time.Millisecond * 200)
assert.Panics(func() {
Start(srv)
}, "not allowed to listen twice")
srv.Close()
}