Ejemplo n.º 1
0
	"net/http"

	"github.com/goadesign/goa"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("PathSelectVersionFunc", func() {
	var pattern, zeroVersion string
	var request *http.Request

	var fn goa.SelectVersionFunc
	var version string

	JustBeforeEach(func() {
		fn = goa.PathSelectVersionFunc(pattern, zeroVersion)
		version = fn(request)
	})

	Context("using the default settings", func() {
		BeforeEach(func() {
			pattern = "/:version/"
			zeroVersion = "api"
		})

		Context("and a versioned request", func() {
			BeforeEach(func() {
				var err error
				request, err = http.NewRequest("GET", "/v1/foo", nil)
				Ω(err).ShouldNot(HaveOccurred())
			})
Ejemplo n.º 2
0
	"github.com/goadesign/goa"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("PathSelectVersionFunc", func() {
	var pattern, param string
	var request *http.Request

	var fn goa.SelectVersionFunc
	var version string

	JustBeforeEach(func() {
		var err error
		fn, err = goa.PathSelectVersionFunc(pattern, param)
		Ω(err).ShouldNot(HaveOccurred())
		version = fn(request)
	})

	Context("using path versioning", func() {
		BeforeEach(func() {
			pattern = "/:version/"
			param = "version"
		})

		Context("and a versioned request", func() {
			BeforeEach(func() {
				var err error
				request, err = http.NewRequest("GET", "/v1/foo", nil)
				Ω(err).ShouldNot(HaveOccurred())