github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/internal/peer/node/rebuild_dbs_test.go (about) 1 /* 2 Copyright hechain. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package node 8 9 import ( 10 "os" 11 "testing" 12 13 "github.com/spf13/viper" 14 "github.com/stretchr/testify/require" 15 ) 16 17 func TestRebuildDBsCmd(t *testing.T) { 18 testPath := "/tmp/hyperledger/test" 19 os.RemoveAll(testPath) 20 viper.Set("peer.fileSystemPath", testPath) 21 defer os.RemoveAll(testPath) 22 23 // this should return an error as no ledger has been set up 24 cmd := rebuildDBsCmd() 25 err := cmd.Execute() 26 // this should return an error as no ledger has been set up 27 require.Contains(t, err.Error(), "error while checking if any ledger has been bootstrapped from snapshot") 28 }