-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathservice_test.go
More file actions
58 lines (44 loc) · 1.19 KB
/
service_test.go
File metadata and controls
58 lines (44 loc) · 1.19 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
package hermes
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"net"
"time"
)
var _ = Describe("Hermes", func() {
Describe("Service", func() {
It("should not start service in a used", func() {
serverPort := ":2699"
firstRouter := DefaultRouter()
firstRouter.Get("/", func(_ Request, res Response) Result {
return res.Data(map[string]string{"test": "true"})
})
firstServer := NewApplication(ApplicationConfig{
Name: "Running test app",
HTTP: FasthttpServiceConfiguration{
Bind: serverPort,
},
}, firstRouter)
go func() {
defer GinkgoRecover()
Expect(firstServer.Start()).ShouldNot(HaveOccurred())
}()
time.Sleep(10 * time.Millisecond)
router := DefaultRouter()
router.Get("/", func(_ Request, res Response) Result {
return res.Data(map[string]string{"test": "false"})
})
server := NewApplication(ApplicationConfig{
Name: "Should brake test app",
HTTP: FasthttpServiceConfiguration{
Bind: serverPort,
},
}, router)
err := server.Start()
var opErr *net.OpError
Expect(err).To(BeAssignableToTypeOf(opErr))
opErr = err.(*net.OpError)
Expect(opErr.Op).To(Equal("listen"))
})
})
})