github.com/anjalikarhana/fabric@v2.1.1+incompatible/orderer/common/blockcutter/metrics_test.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package blockcutter_test
     8  
     9  import (
    10  	. "github.com/onsi/ginkgo"
    11  	. "github.com/onsi/gomega"
    12  
    13  	"github.com/hyperledger/fabric/orderer/common/blockcutter"
    14  	"github.com/hyperledger/fabric/orderer/common/blockcutter/mock"
    15  )
    16  
    17  var _ = Describe("Metrics", func() {
    18  	Describe("NewMetrics", func() {
    19  		var (
    20  			fakeProvider *mock.MetricsProvider
    21  		)
    22  
    23  		BeforeEach(func() {
    24  			fakeProvider = &mock.MetricsProvider{}
    25  			fakeProvider.NewHistogramReturns(&mock.MetricsHistogram{})
    26  		})
    27  
    28  		It("uses the provider to initialize its field", func() {
    29  			metrics := blockcutter.NewMetrics(fakeProvider)
    30  			Expect(metrics).NotTo(BeNil())
    31  			Expect(metrics.BlockFillDuration).To(Equal(&mock.MetricsHistogram{}))
    32  
    33  			Expect(fakeProvider.NewHistogramCallCount()).To(Equal(1))
    34  		})
    35  	})
    36  })