github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/core/common/privdata/collection_test.go (about) 1 /* 2 Copyright hechain. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package privdata 8 9 import ( 10 "testing" 11 12 "github.com/stretchr/testify/require" 13 ) 14 15 func TestBuildCollectionKVSKey(t *testing.T) { 16 chaincodeCollectionKey := BuildCollectionKVSKey("chaincodeKey") 17 require.Equal(t, "chaincodeKey~collection", chaincodeCollectionKey, "collection keys should end in ~collection") 18 } 19 20 func TestIsCollectionConfigKey(t *testing.T) { 21 isCollection := IsCollectionConfigKey("chaincodeKey") 22 require.False(t, isCollection, "key without tilda is not a collection key and should have returned false") 23 24 isCollection = IsCollectionConfigKey("chaincodeKey~collection") 25 require.True(t, isCollection, "key with tilda is a collection key and should have returned true") 26 }