sheddingstat_test.go 440 B

123456789101112131415161718192021222324
  1. package load
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestSheddingStat(t *testing.T) {
  7. st := NewSheddingStat("any")
  8. for i := 0; i < 3; i++ {
  9. st.IncrementTotal()
  10. }
  11. for i := 0; i < 5; i++ {
  12. st.IncrementPass()
  13. }
  14. for i := 0; i < 7; i++ {
  15. st.IncrementDrop()
  16. }
  17. result := st.reset()
  18. assert.Equal(t, int64(3), result.Total)
  19. assert.Equal(t, int64(5), result.Pass)
  20. assert.Equal(t, int64(7), result.Drop)
  21. }