github.com/lyft/flytestdlib@v0.3.12-0.20210213045714-8cdd111ecda1/promutils/labeled/timer_wrapper_test.go (about)

     1  package labeled
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  type fakeTimer struct {
    10  	stopCount int
    11  }
    12  
    13  func (f *fakeTimer) Stop() float64 {
    14  	f.stopCount++
    15  	return 0
    16  }
    17  
    18  func TestTimerStop(t *testing.T) {
    19  	ft := &fakeTimer{}
    20  	tim := timer{
    21  		Timers: []Timer{
    22  			ft, ft, ft,
    23  		},
    24  	}
    25  
    26  	tim.Stop()
    27  	assert.Equal(t, 3, ft.stopCount)
    28  }