优化结构
This commit is contained in:
@@ -2,6 +2,7 @@ package httpx
|
||||
|
||||
import (
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -31,3 +32,15 @@ func TestResponseHelpers(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetCookieUsesRequestedName(t *testing.T) {
|
||||
gin.SetMode(gin.TestMode)
|
||||
r := gin.New()
|
||||
r.GET("/cookie", func(c *gin.Context) { SetCookie(c, "example", "value", 60) })
|
||||
req := httptest.NewRequest("GET", "/cookie", nil)
|
||||
w := httptest.NewRecorder()
|
||||
r.ServeHTTP(w, req)
|
||||
if got := w.Header().Get("Set-Cookie"); !strings.HasPrefix(got, "example=") {
|
||||
t.Fatalf("Set-Cookie = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user