forked from 30x/libgozerian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgo_main_test.go
51 lines (41 loc) · 1.04 KB
/
go_main_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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"os"
"testing"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
const (
testHandler = "testHandler"
testDebug = false
)
func TestGo(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Go Test")
}
var testHTTPServer *gozerianServer
var testURL string
var _ = BeforeSuite(func() {
err := createHandler(testHandler, TestHandlerURI)
Expect(err).Should(Succeed())
testURL = os.Getenv("WEAVER_TEST_URL")
if testURL == "" {
testHTTPServer, err = startGozerianServer(0, "", TestHandlerURI)
Expect(err).Should(Succeed())
testHTTPServer.setDebug(testDebug)
testPort := testHTTPServer.getPort()
Expect(testPort).ShouldNot(BeZero())
testURL = fmt.Sprintf("http://localhost:%d", testPort)
go testHTTPServer.run()
fmt.Fprintf(GinkgoWriter, "Running test against local server on port %d\n", testPort)
} else {
fmt.Printf("Running test against remote server at %s\n", testURL)
}
})
var _ = AfterSuite(func() {
destroyHandler(testHandler)
if testHTTPServer != nil {
testHTTPServer.stop()
}
})