Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F12143069
routes_test.go
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
918 B
Subscribers
None
routes_test.go
View Options
package
writefreely
import
(
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/gorilla/mux"
)
func
TestCacheControlForStaticFiles
(
t
*
testing
.
T
)
{
app
:=
NewApp
(
"testdata/config.ini"
)
if
err
:=
app
.
LoadConfig
();
err
!=
nil
{
t
.
Fatalf
(
"Could not create an app; %v"
,
err
)
}
router
:=
mux
.
NewRouter
()
app
.
InitStaticRoutes
(
router
)
rec
:=
httptest
.
NewRecorder
()
req
:=
httptest
.
NewRequest
(
"GET"
,
"/style.css"
,
nil
)
router
.
ServeHTTP
(
rec
,
req
)
if
code
:=
rec
.
Result
().
StatusCode
;
code
!=
http
.
StatusOK
{
t
.
Fatalf
(
"Could not get /style.css, got HTTP status %d"
,
code
)
}
actual
:=
rec
.
Result
().
Header
.
Get
(
"Cache-Control"
)
expectedDirectives
:=
[]
string
{
"public"
,
"max-age"
,
"immutable"
,
}
for
_
,
expected
:=
range
expectedDirectives
{
if
!
strings
.
Contains
(
actual
,
expected
)
{
t
.
Errorf
(
"Expected Cache-Control header to contain '%s', but was '%s'"
,
expected
,
actual
)
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Oct 10, 4:45 AM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3390505
Attached To
rWF WriteFreely
Event Timeline
Log In to Comment