github.com/renegr87/renegr87@v2.1.1+incompatible/core/common/privdata/collection_test.go (about)

     1  /*
     2  Copyright IBM Corp. 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/assert"
    13  )
    14  
    15  func TestBuildCollectionKVSKey(t *testing.T) {
    16  
    17  	chaincodeCollectionKey := BuildCollectionKVSKey("chaincodeKey")
    18  	assert.Equal(t, "chaincodeKey~collection", chaincodeCollectionKey, "collection keys should end in ~collection")
    19  }
    20  
    21  func TestIsCollectionConfigKey(t *testing.T) {
    22  
    23  	isCollection := IsCollectionConfigKey("chaincodeKey")
    24  	assert.False(t, isCollection, "key without tilda is not a collection key and should have returned false")
    25  
    26  	isCollection = IsCollectionConfigKey("chaincodeKey~collection")
    27  	assert.True(t, isCollection, "key with tilda is a collection key and should have returned true")
    28  }