ensure the client is valid before using it in the tests
@@ -78,6 +78,26 @@ var _ = Describe("Client", func() {
grpcProcess ifrit.Process
)
+ BeforeEach(func() {
+ var err error
+ grpcRunner, err = NewGRPCRunner("fixtures/metron.crt", "fixtures/metron.key", "fixtures/CA.crt")
+ Expect(err).NotTo(HaveOccurred())
+ grpcProcess = ginkgomon.Invoke(grpcRunner)
+
+ config = loggregator_v2.MetronConfig{
+ UseV2API: true,
+ APIPort: grpcRunner.Port(),
+ CACertPath: "fixtures/CA.crt",
+ CertPath: "fixtures/client.crt",
+ KeyPath: "fixtures/client.key",
+ }
+ receivers = grpcRunner.Receivers()
+ })
+
+ AfterEach(func() {
+ ginkgomon.Interrupt(grpcProcess)
+ })
+
Context("the cert or key path are invalid", func() {
BeforeEach(func() {
config.CertPath = "/some/invalid/path"
@@ -108,7 +128,7 @@ var _ = Describe("Client", func() {
})
})
- Context("cannot connecto to the server", func() {
+ Context("cannot connect to the server", func() {
BeforeEach(func() {
config.APIPort = 1234
})
@@ -118,28 +138,10 @@ var _ = Describe("Client", func() {
})
})
- BeforeEach(func() {
- var err error
- grpcRunner, err = NewGRPCRunner("fixtures/metron.crt", "fixtures/metron.key", "fixtures/CA.crt")
- Expect(err).NotTo(HaveOccurred())
- grpcProcess = ginkgomon.Invoke(grpcRunner)
-
- config = loggregator_v2.MetronConfig{
- UseV2API: true,
- APIPort: grpcRunner.Port(),
- CACertPath: "fixtures/CA.crt",
- CertPath: "fixtures/client.crt",
- KeyPath: "fixtures/client.key",
- }
- receivers = grpcRunner.Receivers()
- })
-
- AfterEach(func() {
- ginkgomon.Interrupt(grpcProcess)
- })
-
- It("does not return an error", func() {
+ Context("when valid configuration is used", func() {
+ JustBeforeEach(func() {
Expect(clientErr).NotTo(HaveOccurred())
+ Expect(client).NotTo(BeNil())
})
It("sends app logs", func() {
@@ -226,3 +228,4 @@ var _ = Describe("Client", func() {
})
})
})
+})
