MCPcopy Index your code
hub / github.com/go-dev-frame/sponge / TestServer_New

Function TestServer_New

pkg/httpsrv/http_test.go:10–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestServer_New(t *testing.T) {
11 tests := []struct {
12 name string
13 server *http.Server
14 tlser []TLSer
15 wantError bool
16 }{
17 {
18 name: "create server without TLSer",
19 server: &http.Server{Addr: ":8080"},
20 tlser: nil,
21 wantError: false,
22 },
23 {
24 name: "create server with TLSer",
25 server: &http.Server{Addr: ":8080"},
26 tlser: []TLSer{&mockTLSer{}},
27 wantError: false,
28 },
29 {
30 name: "create server with nil server",
31 server: nil,
32 tlser: nil,
33 wantError: true,
34 },
35 }
36
37 for _, tt := range tests {
38 t.Run(tt.name, func(t *testing.T) {
39 srv := New(tt.server, tt.tlser...)
40 err := srv.validate()
41
42 if (err != nil) != tt.wantError {
43 t.Errorf("validate() error = %v, wantError %v", err, tt.wantError)
44 }
45 })
46 }
47}
48
49func TestServer_Run_HTTP(t *testing.T) {
50 server := &http.Server{

Callers

nothing calls this directly

Calls 4

ErrorfMethod · 0.80
NewFunction · 0.70
RunMethod · 0.65
validateMethod · 0.45

Tested by

no test coverage detected