-
Notifications
You must be signed in to change notification settings - Fork 1
/
server_os_test.go
43 lines (38 loc) · 1.29 KB
/
server_os_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
//go:build !darwin
package wess
import (
"context"
"os"
"github.com/gildas/go-errors"
)
func (suite *ServerSuite) TestShouldFailStartingWithInvalidPort() {
server := NewServer(ServerOptions{
Port: 12,
Logger: suite.Logger,
})
suite.Require().NotNil(server, "Server should not be nil")
shutdown, stop, err := server.Start(context.Background())
if err == nil {
stop <- os.Interrupt
}
suite.Require().Error(err, "Should have failed starting the server")
suite.Logger.Errorf("Expected Error:", err)
suite.Assert().ErrorIs(err, errors.RuntimeError, "Error should have been a RuntimeError but was %T", err)
suite.Assert().Nil(shutdown, "Shutdown channel should be nil")
}
func (suite *ServerSuite) TestShouldFailStartingWithInvalidProbePort() {
server := NewServer(ServerOptions{
Port: 9898,
ProbePort: 15,
Logger: suite.Logger,
})
suite.Require().NotNil(server, "Server should not be nil")
shutdown, stop, err := server.Start(context.Background())
if err == nil {
stop <- os.Interrupt
}
suite.Require().Error(err, "Should have failed starting the server")
suite.Logger.Errorf("Expected Error:", err)
suite.Assert().ErrorIs(err, errors.RuntimeError, "Error should have been a RuntimeError but was %T", err)
suite.Assert().Nil(shutdown, "Shutdown channel should be nil")
}