github.com/msales/pkg/v3@v3.24.0/stats/timer_test.go (about) 1 package stats_test 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/msales/pkg/v3/stats" 8 "github.com/stretchr/testify/mock" 9 ) 10 11 func TestTimer(t *testing.T) { 12 m := new(MockStats) 13 m.On("Timing", "test", mock.Anything, float32(1.0), mock.Anything).Return(nil) 14 15 ctx := stats.WithStats(context.Background(), m) 16 ti := stats.Time(ctx, "test", 1.0) 17 ti.Done() 18 19 m.AssertExpectations(t) 20 }