realize/realize/server_test.go

47 lines
884 B
Go
Raw Normal View History

2017-11-20 15:36:48 +00:00
package realize
2017-12-03 18:06:49 +00:00
import (
"net/http"
"runtime"
2017-12-04 14:53:59 +00:00
"testing"
2017-12-03 18:06:49 +00:00
)
2017-12-04 14:53:59 +00:00
2017-12-03 18:06:49 +00:00
func TestServer_Start(t *testing.T) {
s := Server{
Host: "localhost",
Port: 5000,
}
host := "http://localhost:5000/"
urls := []string{
host,
host + "assets/js/all.min.js",
host + "assets/css/app.css",
host + "app/components/settings/index.html",
host + "app/components/project/index.html",
host + "app/components/project/index.html",
host + "app/components/index.html",
}
err := s.Start()
if err != nil {
t.Fatal(err)
}
for _, elm := range urls {
resp, err := http.Get(elm)
if err != nil || resp.StatusCode != 200 {
t.Fatal(err, resp.StatusCode, elm)
}
}
}
func TestServer_Open(t *testing.T) {
cmd := map[string]string{
"windows": "start",
"darwin": "open",
"linux": "xdg-open",
}
key := runtime.GOOS
2017-12-04 14:53:59 +00:00
if _, ok := cmd[key]; !ok {
2017-12-03 18:06:49 +00:00
t.Error("System not supported")
}
2017-12-04 14:53:59 +00:00
}