forked from goadesign/goa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmux_test.go
44 lines (35 loc) · 860 Bytes
/
mux_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package goa_test
import (
"net/http"
"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())
})
It("routes to the versioned controller", func() {
Ω(version).Should(Equal("v1"))
})
})
})
})