forked from NXRSE/bank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server_test.go
45 lines (37 loc) · 890 Bytes
/
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 main
import (
"net"
"testing"
)
func TestRunTLSServer(t *testing.T) {
//@TODO Figure out how to exit this when successful
/*
errs := make(chan *bankError, 1)
go func() {
_, err := runServer("tls")
if err != nil {
errs <- err
}
close(errs)
return
}()
for err := range errs {
if err != nil {
t.Errorf("RunTLSServer does not pass. Looking for %v, got %v", nil, errs)
}
}
*/
}
//@TODO Implement TCP (no TLS) when exit if successful implemented
func TestHandleTCPRequest(t *testing.T) {
l, err := net.Listen(CONN_TYPE, CONN_HOST+":"+CONN_PORT)
if err != nil {
t.Errorf("HandleRequest does not pass. Does not Listen. Looking for %v, got %v", nil, err)
}
conn, err := l.Accept()
bankErr := handleTCPRequest(conn)
l.Close()
if bankErr != nil {
t.Errorf("HandleRequest does not pass. Looking for %v, got %v", nil, bankErr)
}
}