Refactor into server object to handle registered accounts

This commit is contained in:
Marc Di Luzio 2020-05-31 11:18:26 +01:00
parent eccb726f74
commit 93decc027b
13 changed files with 304 additions and 128 deletions

25
pkg/server/router_test.go Normal file
View file

@ -0,0 +1,25 @@
package server
import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
)
func TestHandleStatus(t *testing.T) {
request, _ := http.NewRequest(http.MethodGet, "/status", nil)
response := httptest.NewRecorder()
s := NewServer(8080)
s.Initialise()
s.HandleStatus(response, request)
var status StatusResponse
json.NewDecoder(response.Body).Decode(&status)
if status.Ready != true {
t.Errorf("got false for /status")
}
}