github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/cmd/discover/main_test.go (about) 1 /* 2 Copyright hechain. 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 "time" 13 14 . "github.com/onsi/gomega" 15 "github.com/onsi/gomega/gbytes" 16 . "github.com/onsi/gomega/gexec" 17 ) 18 19 func TestMissingArguments(t *testing.T) { 20 gt := NewGomegaWithT(t) 21 discover, err := Build("github.com/hechain20/hechain/cmd/discover") 22 gt.Expect(err).NotTo(HaveOccurred()) 23 defer CleanupBuildArtifacts() 24 25 // key and cert flags are missing 26 cmd := exec.Command(discover, "--configFile", "conf.yaml", "--MSP", "SampleOrg", "saveConfig") 27 process, err := Start(cmd, nil, nil) 28 gt.Expect(err).NotTo(HaveOccurred()) 29 gt.Eventually(process, 5*time.Second).Should(Exit(1)) 30 gt.Expect(process.Err).To(gbytes.Say("empty string that is mandatory")) 31 }