mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
311b560717
Former-commit-id: c797e23c78b1e74bbe9ba56673f3a98f17f5e2f7
27 lines
876 B
Go
27 lines
876 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/kataras/iris/v12"
|
|
"github.com/kataras/iris/v12/httptest"
|
|
"github.com/kataras/iris/v12/versioning"
|
|
)
|
|
|
|
func TestVersionedController(t *testing.T) {
|
|
app := newApp()
|
|
|
|
e := httptest.New(t, app)
|
|
e.GET("/data").WithHeader(versioning.AcceptVersionHeaderKey, "1").Expect().
|
|
Status(iris.StatusOK).Body().Equal("data (v1.x)")
|
|
e.GET("/data").WithHeader(versioning.AcceptVersionHeaderKey, "2.3.0").Expect().
|
|
Status(iris.StatusOK).Body().Equal("data (v2.x)")
|
|
e.GET("/data").WithHeader(versioning.AcceptVersionHeaderKey, "3.1").Expect().
|
|
Status(iris.StatusOK).Body().Equal("data (v3.x)")
|
|
// Test invalid version or no version at all.
|
|
e.GET("/data").WithHeader(versioning.AcceptVersionHeaderKey, "4").Expect().
|
|
Status(iris.StatusOK).Body().Equal("data")
|
|
e.GET("/data").Expect().
|
|
Status(iris.StatusOK).Body().Equal("data")
|
|
}
|