chore: add more tests (#3018)
This commit is contained in:
@@ -28,7 +28,8 @@ func TestNewServer(t *testing.T) {
|
||||
|
||||
const configYaml = `
|
||||
Name: foo
|
||||
Port: 54321
|
||||
Host: localhost
|
||||
Port: 0
|
||||
`
|
||||
var cnf RestConf
|
||||
assert.Nil(t, conf.LoadFromYamlBytes([]byte(configYaml), &cnf))
|
||||
@@ -101,6 +102,23 @@ Port: 54321
|
||||
svr.Start()
|
||||
svr.Stop()
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
p := recover()
|
||||
switch v := p.(type) {
|
||||
case error:
|
||||
assert.Equal(t, "foo", v.Error())
|
||||
default:
|
||||
t.Fail()
|
||||
}
|
||||
}()
|
||||
|
||||
svr.StartWithOpts(func(svr *http.Server) {
|
||||
svr.RegisterOnShutdown(func() {})
|
||||
})
|
||||
svr.Stop()
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,7 +587,6 @@ Port: 54321
|
||||
Method: http.MethodGet,
|
||||
Path: "/user/:name",
|
||||
Handler: func(writer http.ResponseWriter, request *http.Request) {
|
||||
|
||||
var userInfo struct {
|
||||
Name string `path:"name"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user