I wanna start my app in BeforeSuit and run a GET Request. Is that possible?
example_suite_test.go
func TestExample(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Example Suite")
}
example_test.go
var appTest *app.Application
var _ = BeforeSuite(func() {
app = &app.Application{}
app.Run(":8080") // runs http.ListenAndServe on given address
})
var _ = Describe("Example", func() {
Context("When calling '/example' endpoint...", func() {
req, err := http.NewRequest("GET", "http://localhost:8080/example", nil)
client := http.DefaultClient
res, err := client.Do(req)
It("Should get response 200 OK", func() {
Expect(res.Status).To(Equal("200 OK"))
})
})
})
At the moment it seems to start the server and not continue with the test. If I remove the BeforeSuite and instead start the server and run the test it seems fine.