mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 09:00:20 +08:00
24 lines
532 B
Go
24 lines
532 B
Go
package internal
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetTimeout(t *testing.T) {
|
|
req := httptest.NewRequest("GET", "/", http.NoBody)
|
|
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", "/", http.NoBody)
|
|
timeout := GetTimeout(req.Header, time.Second*5)
|
|
assert.Equal(t, time.Second*5, timeout)
|
|
}
|