Last active
March 26, 2017 21:24
-
-
Save jwieringa/acbecf7ea791f4ba41315947bc770053 to your computer and use it in GitHub Desktop.
Trying out Rspec style test via Golang in Ginkgo/Gomega
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package resource_proxy_integration | |
import ( | |
. "github.com/onsi/ginkgo" | |
. "github.com/onsi/gomega" | |
"log" | |
"net/http" | |
"testing" | |
) | |
func TestResourceProxy(t *testing.T) { | |
RegisterFailHandler(Fail) | |
RunSpecs(t, "Resource Proxy") | |
} | |
func get(path string) *http.Response { | |
resp, err := http.Get("http://opendata.arcgis.com/" + path) | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer resp.Body.Close() | |
return resp | |
} | |
var _ = Describe("Resource Proxy", func() { | |
It("it should return 200", func() { | |
resp := get("datasets") | |
Expect(resp.Status).To(Equal("200 OK")) | |
}) | |
// This spec is an example of a failure | |
It("it should return 200", func() { | |
resp := get("datasets") | |
Expect(resp.Status).To(Equal("404")) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment