github.com/ewagmig/fabric@v2.1.1+incompatible/cmd/discover/main_test.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package main
     8  
     9  import (
    10  	"os/exec"
    11  	"testing"
    12  
    13  	. "github.com/onsi/gomega"
    14  	"github.com/onsi/gomega/gbytes"
    15  	. "github.com/onsi/gomega/gexec"
    16  )
    17  
    18  func TestMissingArguments(t *testing.T) {
    19  	gt := NewGomegaWithT(t)
    20  	discover, err := Build("github.com/hyperledger/fabric/cmd/discover")
    21  	gt.Expect(err).NotTo(HaveOccurred())
    22  	defer CleanupBuildArtifacts()
    23  
    24  	// key and cert flags are missing
    25  	cmd := exec.Command(discover, "--configFile", "conf.yaml", "--MSP", "SampleOrg", "saveConfig")
    26  	process, err := Start(cmd, nil, nil)
    27  	gt.Expect(err).NotTo(HaveOccurred())
    28  	gt.Eventually(process).Should(Exit(1))
    29  	gt.Expect(process.Err).To(gbytes.Say("empty string that is mandatory"))
    30  }