github.com/lzy4123/fabric@v2.1.1+incompatible/common/metrics/disabled/provider_test.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package disabled_test 8 9 import ( 10 "github.com/hyperledger/fabric/common/metrics" 11 "github.com/hyperledger/fabric/common/metrics/disabled" 12 . "github.com/onsi/ginkgo" 13 . "github.com/onsi/gomega" 14 ) 15 16 var _ = Describe("Provider", func() { 17 var p metrics.Provider 18 19 BeforeEach(func() { 20 p = &disabled.Provider{} 21 }) 22 23 Describe("NewCounter", func() { 24 It("creates a no-op counter that doesn't blow up", func() { 25 c := p.NewCounter(metrics.CounterOpts{}) 26 Expect(c).NotTo(BeNil()) 27 28 c.Add(1) 29 c.With("whatever").Add(2) 30 }) 31 }) 32 33 Describe("NewGauge", func() { 34 It("creates a no-op gauge that doesn't blow up", func() { 35 g := p.NewGauge(metrics.GaugeOpts{}) 36 Expect(g).NotTo(BeNil()) 37 38 g.Set(1) 39 g.Add(1) 40 g.With("whatever").Set(2) 41 g.With("whatever").Add(2) 42 }) 43 }) 44 45 Describe("NewHistogram", func() { 46 It("creates a no-op histogram that doesn't blow up", func() { 47 h := p.NewHistogram(metrics.HistogramOpts{}) 48 Expect(h).NotTo(BeNil()) 49 50 h.Observe(1) 51 h.With("whatever").Observe(2) 52 }) 53 }) 54 })