(t *testing.T)
| 518 | } |
| 519 | |
| 520 | func TestWithTimeout(t *testing.T) { |
| 521 | t.Parallel() |
| 522 | |
| 523 | t.Run("negative_timeout", func(t *testing.T) { |
| 524 | t.Parallel() |
| 525 | |
| 526 | opts := clientOptions{} |
| 527 | err := WithTimeout(-1)(&opts) |
| 528 | if err == nil || err.Error() != "timeout must not be negative" { |
| 529 | t.Errorf("WithTimeout errored: %v", err) |
| 530 | } |
| 531 | }) |
| 532 | |
| 533 | t.Run("zero_timeout", func(t *testing.T) { |
| 534 | t.Parallel() |
| 535 | |
| 536 | opts := clientOptions{} |
| 537 | err := WithTimeout(0)(&opts) |
| 538 | if err != nil { |
| 539 | t.Fatalf("WithTimeout errored: %v", err) |
| 540 | } |
| 541 | |
| 542 | if opts.timeout == nil || *opts.timeout != 0 { |
| 543 | t.Errorf("timeout = %v, want 0", opts.timeout) |
| 544 | } |
| 545 | }) |
| 546 | |
| 547 | t.Run("valid_timeout", func(t *testing.T) { |
| 548 | t.Parallel() |
| 549 | |
| 550 | timeout := 10 * time.Second |
| 551 | opts := clientOptions{} |
| 552 | err := WithTimeout(timeout)(&opts) |
| 553 | if err != nil { |
| 554 | t.Fatalf("WithTimeout errored: %v", err) |
| 555 | } |
| 556 | |
| 557 | if opts.timeout == nil || *opts.timeout != timeout { |
| 558 | t.Errorf("timeout = %v, want %v", opts.timeout, timeout) |
| 559 | } |
| 560 | }) |
| 561 | } |
| 562 | |
| 563 | func TestWithUserAgent(t *testing.T) { |
| 564 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…