ops_repo_dashboard_timeout_test.go 662 B

12345678910111213141516171819202122
  1. package repository
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. )
  7. func TestIsQueryTimeoutErr(t *testing.T) {
  8. if !isQueryTimeoutErr(context.DeadlineExceeded) {
  9. t.Fatalf("context.DeadlineExceeded should be treated as query timeout")
  10. }
  11. if !isQueryTimeoutErr(fmt.Errorf("wrapped: %w", context.DeadlineExceeded)) {
  12. t.Fatalf("wrapped context.DeadlineExceeded should be treated as query timeout")
  13. }
  14. if isQueryTimeoutErr(context.Canceled) {
  15. t.Fatalf("context.Canceled should not be treated as query timeout")
  16. }
  17. if isQueryTimeoutErr(fmt.Errorf("wrapped: %w", context.Canceled)) {
  18. t.Fatalf("wrapped context.Canceled should not be treated as query timeout")
  19. }
  20. }