MCPcopy Index your code
hub / github.com/google/go-github / TestWithTimeout

Function TestWithTimeout

github/github_test.go:520–561  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

518}
519
520func 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
563func TestWithUserAgent(t *testing.T) {
564 t.Parallel()

Callers

nothing calls this directly

Calls 3

WithTimeoutFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…