github.com/iotexproject/iotex-core@v1.14.1-rc1/pkg/prometheustimer/timer_test.go (about)

     1  // Copyright (c) 2018 IoTeX
     2  // This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability
     3  // or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed.
     4  // This source code is governed by Apache License 2.0 that can be found in the LICENSE file.
     5  
     6  package prometheustimer
     7  
     8  import (
     9  	"testing"
    10  
    11  	"github.com/stretchr/testify/require"
    12  )
    13  
    14  func TestPrometheusTimer(t *testing.T) {
    15  	require := require.New(t)
    16  	factory, err := New("test", "test", []string{"default"}, nil)
    17  	require.Error(err)
    18  	require.Nil(factory)
    19  	timer := factory.NewTimer("test")
    20  	require.NotNil(timer)
    21  	factory, err = New("test", "test", []string{"default"}, []string{"default"})
    22  	require.NoError(err)
    23  	require.NotNil(factory)
    24  	timer = factory.NewTimer("label")
    25  	require.NotNil(timer)
    26  }