Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
561B

  1. package icecast
  2. import (
  3. "testing"
  4. "time"
  5. )
  6. func TestNextBackoff(t *testing.T) {
  7. cfg := ReconnectConfig{
  8. Enabled: true,
  9. InitialBackoffMs: 1000,
  10. MaxBackoffMs: 5000,
  11. }
  12. if got := cfg.nextBackoff(1); got != 1*time.Second {
  13. t.Fatalf("attempt1 got %s", got)
  14. }
  15. if got := cfg.nextBackoff(2); got != 2*time.Second {
  16. t.Fatalf("attempt2 got %s", got)
  17. }
  18. if got := cfg.nextBackoff(3); got != 4*time.Second {
  19. t.Fatalf("attempt3 got %s", got)
  20. }
  21. if got := cfg.nextBackoff(4); got != 5*time.Second {
  22. t.Fatalf("attempt4 got %s", got)
  23. }
  24. }