-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassets_test.go
More file actions
42 lines (33 loc) · 811 Bytes
/
assets_test.go
File metadata and controls
42 lines (33 loc) · 811 Bytes
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
package main
import (
"github.com/go-chi/chi"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"net/http"
"net/http/httptest"
)
var _ = Describe("assets.go", func() {
Describe("#Dir", func() {
It("serves static assets", func() {
r := chi.NewMux()
r.Handle("/*", http.FileServer(Dir(false, "/assets")))
ts := httptest.NewServer(r)
defer ts.Close()
res, err := http.Get(ts.URL)
if err != nil {
Fail(err.Error())
}
Expect(res.StatusCode).To(Equal(http.StatusOK))
res, err = http.Get(ts.URL + "/js/index.js")
if err != nil {
Fail(err.Error())
}
Expect(res.StatusCode).To(Equal(http.StatusOK))
res, err = http.Get(ts.URL + "/index.html")
if err != nil {
Fail(err.Error())
}
Expect(res.StatusCode).To(Equal(http.StatusOK))
})
})
})