You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
504 B
Go
23 lines
504 B
Go
2 years ago
|
package internal
|
||
|
|
||
|
import (
|
||
|
"net/http/httptest"
|
||
|
"testing"
|
||
|
"time"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestGetTimeout(t *testing.T) {
|
||
|
req := httptest.NewRequest("GET", "/", nil)
|
||
|
req.Header.Set(grpcTimeoutHeader, "1s")
|
||
|
timeout := GetTimeout(req.Header, time.Second*5)
|
||
|
assert.Equal(t, time.Second, timeout)
|
||
|
}
|
||
|
|
||
|
func TestGetTimeoutDefault(t *testing.T) {
|
||
|
req := httptest.NewRequest("GET", "/", nil)
|
||
|
timeout := GetTimeout(req.Header, time.Second*5)
|
||
|
assert.Equal(t, time.Second*5, timeout)
|
||
|
}
|