WebUI/src/server/middleware/cache_test.go
Theta-Dev 60034b4815
All checks were successful
continuous-integration/drone/push Build is passing
add server base
2022-02-01 23:08:45 +01:00

25 lines
575 B
Go

package middleware
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
)
func TestCache(t *testing.T) {
router := gin.New()
router.Use(Cache)
router.GET("/", func(c *gin.Context) { c.String(http.StatusOK, "HelloWorld") })
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/", nil)
router.ServeHTTP(w, req)
assert.Equal(t, http.StatusOK, w.Code)
assert.Equal(t, "HelloWorld", w.Body.String())
assert.Equal(t, "public, max-age=604800, immutable",
w.Header().Get("Cache-Control"))
}