mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 18:37:05 +00:00
nothing important here
Former-commit-id: e6c4ade12d085cb8fa4989b15fa446b75ee114b2
This commit is contained in:
@@ -17,7 +17,7 @@ func TestSessions(t *testing.T) {
|
||||
}
|
||||
|
||||
const (
|
||||
testEnableSubdomain = false
|
||||
testEnableSubdomain = true
|
||||
)
|
||||
|
||||
func testSessions(t *testing.T, sess *sessions.Sessions, app *iris.Application) {
|
||||
@@ -35,16 +35,14 @@ func testSessions(t *testing.T, sess *sessions.Sessions, app *iris.Application)
|
||||
}
|
||||
|
||||
if testEnableSubdomain {
|
||||
app.Party("subdomain.").Get("/get", func(ctx context.Context) {
|
||||
writeValues(ctx)
|
||||
})
|
||||
app.Party("subdomain.").Get("/get", writeValues)
|
||||
}
|
||||
|
||||
app.Post("/set", func(ctx context.Context) {
|
||||
s := sess.Start(ctx)
|
||||
vals := make(map[string]interface{}, 0)
|
||||
if err := ctx.ReadJSON(&vals); err != nil {
|
||||
t.Fatalf("Cannot readjson. Trace %s", err.Error())
|
||||
t.Fatalf("Cannot read JSON. Trace %s", err.Error())
|
||||
}
|
||||
for k, v := range vals {
|
||||
s.Set(k, v)
|
||||
@@ -84,10 +82,11 @@ func testSessions(t *testing.T, sess *sessions.Sessions, app *iris.Application)
|
||||
e.POST("/set").WithJSON(values).Expect().Status(iris.StatusOK).Cookies().NotEmpty()
|
||||
e.GET("/get").Expect().Status(iris.StatusOK).JSON().Object().Equal(values)
|
||||
if testEnableSubdomain {
|
||||
es := httptest.New(t, app, httptest.URL("http://subdomain.example.com"))
|
||||
es := e.Builder(func(req *httptest.Request) {
|
||||
req.WithURL("http://subdomain.example.com")
|
||||
})
|
||||
es.Request("GET", "/get").Expect().Status(iris.StatusOK).JSON().Object().Equal(values)
|
||||
}
|
||||
|
||||
// test destroy which also clears first
|
||||
d := e.GET("/destroy").Expect().Status(iris.StatusOK)
|
||||
d.JSON().Object().Empty()
|
||||
|
||||
Reference in New Issue
Block a user