Skip to content

Instantly share code, notes, and snippets.

@hoegaarden
Created February 6, 2018 16:35
Show Gist options
  • Save hoegaarden/b2331a481a46ef017d3d7e99d190d95c to your computer and use it in GitHub Desktop.
Save hoegaarden/b2331a481a46ef017d3d7e99d190d95c to your computer and use it in GitHub Desktop.
go test
package integration_tests
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/kubernetes-sig-testing/frameworks/integration"
)
var _ = Describe("APIServer", func() {
Context("when no EtcdURL is provided", func() {
It("does not panic", func() {
apiServer := &APIServer{}
starter := func() {
Expect(apiServer.Start()).To(
MatchError(ContainSubstring("expected EtcdURL to be configured")),
)
}
Expect(starter).NotTo(Panic())
})
})
})
package integration_tests
import (
"testing"
. "github.com/kubernetes-sig-testing/frameworks/integration"
)
func TestNoEtcdURL(t *testing.T) {
defer func() {
if r := recover(); r != nil {
t.Fatalf("Should not have paniced: %s", r)
}
}()
apiServer := &APIServer{}
starter := func() {
err := apiServer.Start()
expected := "expected EtcdURL to be configured"
if err == nil || err.Error() != expected {
t.Fatalf("Expected error to be '%s'", expected)
}
}
starter()
}
package integration_tests
import (
"testing"
. "github.com/kubernetes-sig-testing/frameworks/integration"
. "github.com/onsi/gomega"
)
func TestNoEtcdURL(t *testing.T) {
g := NewGomegaWithT(t)
apiServer := &APIServer{}
starter := func() {
expected := "expected EtcdURL to be configured"
g.Expect(apiServer.Start()).To(MatchError(expected))
}
g.Expect(starter).NotTo(Panic())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment