First test
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
package control
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ControlServer struct {
|
||||||
|
bindAddr string
|
||||||
|
mux *http.ServeMux
|
||||||
|
traceChannel chan string
|
||||||
|
certfile string
|
||||||
|
keyfile string
|
||||||
|
}
|
||||||
|
|
||||||
|
var server *ControlServer
|
||||||
|
|
||||||
|
func NewControlServer(bindAddr string, listenPort int, certfile, keyfile string) *ControlServer {
|
||||||
|
|
||||||
|
if server == nil {
|
||||||
|
server = &ControlServer{bindAddr: fmt.Sprintf("%s:%d", bindAddr, listenPort),
|
||||||
|
certfile: certfile,
|
||||||
|
keyfile: keyfile}
|
||||||
|
}
|
||||||
|
|
||||||
|
return server
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ControlServer) Start(traceChannel chan string) {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package control
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestNewControlServerFillsTheStruct(t *testing.T) {
|
||||||
|
|
||||||
|
server := NewControlServer("0.0.0.0", 8080, "/certfile.pem", "/keyfile.pem")
|
||||||
|
|
||||||
|
if server.bindAddr != "0.0.0.0:8080" {
|
||||||
|
t.Errorf("BindAddress incorrectly composed. Expected: %s, got: %s", "0.0.0.0:8080", server.bindAddr)
|
||||||
|
}
|
||||||
|
|
||||||
|
if server.certfile != "/certfile.pem" {
|
||||||
|
t.Errorf("BindAddress incorrectly composed. Expected: %s, got: %s", "/certfile.pem", server.certfile)
|
||||||
|
}
|
||||||
|
|
||||||
|
if server.keyfile != "/keyfile.pem" {
|
||||||
|
t.Errorf("BindAddress incorrectly composed. Expected: %s, got: %s", "/keyfile.pem", server.keyfile)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user