-
Notifications
You must be signed in to change notification settings - Fork 9
/
server_test.go
45 lines (43 loc) · 1.01 KB
/
server_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package orchestra
import (
"net/http"
"reflect"
"testing"
"time"
)
func TestNewServerPlayer(t *testing.T) {
type args struct {
srv *http.Server
opts []ServerPlayerOption
}
tests := []struct {
name string
args args
want *ServerPlayer
}{
{
name: "default",
args: args{},
want: &ServerPlayer{server: &http.Server{}, shutdownTimeout: time.Second * 10},
},
{
name: "set timeout to 5s",
args: args{opts: []ServerPlayerOption{
WithShutdownTimeout(time.Second * 5),
}},
want: &ServerPlayer{server: &http.Server{}, shutdownTimeout: time.Second * 5},
},
{
name: "replace default http server",
args: args{srv: &http.Server{Addr: ":4321"}},
want: &ServerPlayer{server: &http.Server{Addr: ":4321"}, shutdownTimeout: time.Second * 10},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewServerPlayer(tt.args.srv, tt.args.opts...); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewServerPlayer() = %v, want %v", got, tt.want)
}
})
}
}