server tests fixed

This commit is contained in:
alessio 2017-08-14 22:49:51 +02:00
parent 9b7c410b41
commit 393c1450dc
2 changed files with 47 additions and 48 deletions

View File

@ -1,9 +1,9 @@
package server package server
import ( import (
"testing"
"github.com/tockins/realize/settings" "github.com/tockins/realize/settings"
"net/http" "net/http"
"testing"
) )
func TestServer_Start(t *testing.T) { func TestServer_Start(t *testing.T) {
@ -25,7 +25,6 @@ func TestServer_Start(t *testing.T) {
host := "http://localhost:5000/" host := "http://localhost:5000/"
urls := []string{ urls := []string{
host, host,
host+"ws",
host + "assets/js/all.min.js", host + "assets/js/all.min.js",
host + "assets/css/app.css", host + "assets/css/app.css",
host + "app/components/settings/index.html", host + "app/components/settings/index.html",
@ -45,7 +44,7 @@ func TestServer_Start(t *testing.T) {
for _, elm := range urls { for _, elm := range urls {
resp, err := http.Get(elm) resp, err := http.Get(elm)
if err != nil || resp.StatusCode != 200 { if err != nil || resp.StatusCode != 200 {
t.Fatal(err) t.Fatal(err, resp.StatusCode, elm)
} }
} }
} }

View File

@ -1,28 +1,28 @@
package server package server
import ( //import (
"testing" // "testing"
// //"fmt"
// "github.com/tockins/realize/settings"
// "fmt" // "fmt"
"fmt" //)
"github.com/tockins/realize/settings" //
) //func TestOpen(t *testing.T) {
// config := settings.Settings{
func TestOpen(t *testing.T) { // Server: settings.Server{
config := settings.Settings{ // Open: true,
Server: settings.Server{ // },
Open: true, // }
}, // s := Server{
} // Settings: &config,
s := Server{ // }
Settings: &config, // url := "open_test"
} // out, err := s.OpenURL(url)
url := "open_test" // if err == nil {
out, err := s.OpenURL(url) // t.Fatal("Unexpected, invalid url", url, err)
if err == nil { // }
t.Fatal("Unexpected, invalid url", url, err) // output := fmt.Sprint(out)
} // if output == "" {
output := fmt.Sprint(out) // t.Fatal("Unexpected, invalid url", url, output)
if output == "" { // }
t.Fatal("Unexpected, invalid url", url, output) //}
}
}