-
Notifications
You must be signed in to change notification settings - Fork 8
/
gobank_suite_test.go
45 lines (33 loc) · 948 Bytes
/
gobank_suite_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
package gobank_test
import (
"net/http"
"os"
"testing"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/parnurzeal/gorequest"
)
var MountebankURI string
func TestMountebank(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Mountebank Integration Test Suite")
}
var _ = BeforeSuite(func() {
MountebankURI = os.Getenv("MOUNTEBANK_URI")
if len(MountebankURI) == 0 {
MountebankURI = "http://localhost:2525"
}
Expect(isMountebankRunning(MountebankURI)).To(BeTrue(), "Mountebank is not running")
truncateMountebank(MountebankURI)
})
var _ = AfterSuite(func() {
})
func isMountebankRunning(mountebankBaseURI string) bool {
resp, _, errs := gorequest.New().Get(mountebankBaseURI).End()
Expect(errs).To(HaveLen(0))
return resp.StatusCode == http.StatusOK
}
func truncateMountebank(mountebankBaseURI string) {
impostersURI := mountebankBaseURI + "/imposters"
gorequest.New().Delete(impostersURI).End()
}