forked from glycerine/goq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb_test.go
35 lines (28 loc) · 901 Bytes
/
web_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
package main
import (
"strings"
"testing"
cv "github.com/glycerine/goconvey/convey"
)
func TestWebGoesUpAndDown(t *testing.T) {
// *** universal test cfg setup
skipbye := false
cfg := NewTestConfig() // bumps cfg.TestportBump so cfg.GetWebPort() is different in test.
defer cfg.ByeTestConfig(&skipbye)
// *** end universal test setup
s := NewWebServer()
cv.Convey("NewWebServer() should bring up a debug web-server", t, func() {
cv.So(PortIsBound(s.Addr), cv.ShouldEqual, true)
by, err := FetchUrl("http://" + s.Addr + "/debug/pprof")
cv.So(err, cv.ShouldEqual, nil)
//fmt.Printf("by:'%s'\n", string(by))
cv.So(strings.HasPrefix(string(by), `<html>
<head>
<title>/debug/pprof/</title>
</head>`), cv.ShouldEqual, true)
})
cv.Convey("WebServer::Stop() should bring down the debug web-server", t, func() {
s.Stop()
cv.So(PortIsBound(s.Addr), cv.ShouldEqual, false)
})
}