Created
February 6, 2018 16:35
-
-
Save hoegaarden/b2331a481a46ef017d3d7e99d190d95c to your computer and use it in GitHub Desktop.
go test
This file contains 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 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()) | |
}) | |
}) | |
}) |
This file contains 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 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() | |
} |
This file contains 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 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