diff --git a/integration/runner/idemixgen_test.go b/integration/runner/idemixgen_test.go index 715384fc2f3..367c04b5120 100644 --- a/integration/runner/idemixgen_test.go +++ b/integration/runner/idemixgen_test.go @@ -16,18 +16,20 @@ import ( . "github.com/onsi/gomega" "github.com/tedsuo/ifrit" + "github.com/tedsuo/ifrit/ginkgomon" ) var _ = Describe("Idemixgen", func() { - var idemixgen *runner.Idemixgen - var tempDir string - var err error - tempDir, err = ioutil.TempDir("", "idemix") - if err != nil { - Fail("Failed to create test directory") - } + var ( + idemixgen *runner.Idemixgen + tempDir string + ) BeforeEach(func() { + var err error + tempDir, err = ioutil.TempDir("", "idemix") + Expect(err).NotTo(HaveOccurred()) + idemixgen = &runner.Idemixgen{ Path: components.Paths["idemixgen"], EnrollID: "IdeMixUser1", @@ -36,43 +38,53 @@ var _ = Describe("Idemixgen", func() { } }) - It("creates a runner that calls idemixgen ca-keygen", func() { - igRunner := idemixgen.CAKeyGen() - process := ifrit.Invoke(igRunner) - Eventually(process.Ready()).Should(BeClosed()) - Eventually(process.Wait()).Should(Receive(BeNil())) - Expect(igRunner.ExitCode()).To(Equal(0)) - - Expect(filepath.Join(tempDir, "ca")).To(BeADirectory()) - Expect(filepath.Join(tempDir, "msp")).To(BeADirectory()) + AfterEach(func() { + os.RemoveAll(tempDir) }) - Context("when idemixgen ca-keygen fails", func() { - It("returns an error", func() { - igRunner := idemixgen.CAKeyGen("bogus") + Describe("CAKeyGen", func() { + It("creates a runner that calls idemixgen ca-keygen", func() { + igRunner := idemixgen.CAKeyGen() process := ifrit.Invoke(igRunner) - Eventually(process.Wait()).Should(Receive(HaveOccurred())) - }) - }) + Eventually(process.Ready()).Should(BeClosed()) + Eventually(process.Wait()).Should(Receive(BeNil())) + Expect(igRunner.ExitCode()).To(Equal(0)) - It("creates a runner that calls idemixgen signerconfig", func() { - igRunner := idemixgen.SignerConfig() - process := ifrit.Invoke(igRunner) - Eventually(process.Ready()).Should(BeClosed()) - Eventually(process.Wait()).Should(Receive(BeNil())) - Expect(igRunner.ExitCode()).To(Equal(0)) + Expect(filepath.Join(tempDir, "ca")).To(BeADirectory()) + Expect(filepath.Join(tempDir, "msp")).To(BeADirectory()) + }) - Expect(filepath.Join(tempDir, "user")).To(BeADirectory()) + Context("when idemixgen ca-keygen fails", func() { + It("returns an error", func() { + igRunner := idemixgen.CAKeyGen("bogus") + process := ifrit.Invoke(igRunner) + Eventually(process.Wait()).Should(Receive(HaveOccurred())) + }) + }) }) - Context("when idemixgen signerconfig fails", func() { - It("returns an error", func() { - igRunner := idemixgen.SignerConfig("bogus") + Describe("SignerConfig", func() { + BeforeEach(func() { + keygen := ginkgomon.Invoke(idemixgen.CAKeyGen()) + Eventually(keygen.Wait()).Should(Receive(BeNil())) + }) + + It("creates a runner that calls idemixgen signerconfig", func() { + igRunner := idemixgen.SignerConfig() process := ifrit.Invoke(igRunner) - Eventually(process.Wait()).Should(Receive(HaveOccurred())) + Eventually(process.Ready()).Should(BeClosed()) + Eventually(process.Wait()).Should(Receive(BeNil())) + Expect(igRunner.ExitCode()).To(Equal(0)) + + Expect(filepath.Join(tempDir, "user")).To(BeADirectory()) }) - }) - // cleanup - os.RemoveAll(tempDir) + Context("when idemixgen signerconfig fails", func() { + It("returns an error", func() { + igRunner := idemixgen.SignerConfig("bogus") + process := ifrit.Invoke(igRunner) + Eventually(process.Wait()).Should(Receive(HaveOccurred())) + }) + }) + }) })