github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/core/ledger/cceventmgmt/defs_test.go (about)

     1  /*
     2  Copyright hechain. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package cceventmgmt
     8  
     9  import (
    10  	"testing"
    11  
    12  	"github.com/stretchr/testify/require"
    13  )
    14  
    15  func TestChaincodeDefinitionStringer(t *testing.T) {
    16  	tests := []struct {
    17  		cd  *ChaincodeDefinition
    18  		str string
    19  	}{
    20  		{cd: nil, str: "<nil>"},
    21  		{cd: &ChaincodeDefinition{}, str: "Name=, Version=, Hash="},
    22  		{
    23  			cd:  &ChaincodeDefinition{Name: "the-name", Version: "the-version", Hash: []byte{0, 1, 2, 3, 4, 5, 6, 7, 8}},
    24  			str: "Name=the-name, Version=the-version, Hash=000102030405060708",
    25  		},
    26  	}
    27  
    28  	for _, tt := range tests {
    29  		require.Equalf(t, tt.str, tt.cd.String(), "want %s, got %s", tt.str, tt.cd.String())
    30  	}
    31  }