-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatic_test.go
More file actions
46 lines (34 loc) · 824 Bytes
/
static_test.go
File metadata and controls
46 lines (34 loc) · 824 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
43
44
45
46
package kid
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
)
func TestAppendSlash(t *testing.T) {
path := "/static"
assert.Equal(t, "/static/", appendSlash(path))
path = path + "/"
assert.Equal(t, "/static/", appendSlash(path))
}
func TestNewFileServer(t *testing.T) {
assert.Panics(t, func() {
newFileServer("/static/", nil)
})
fileServer := newFileServer("/static/", http.Dir("/var/www"))
assert.NotNil(t, fileServer)
}
func TestFile_Readdir(t *testing.T) {
var f File
info, err := f.Readdir(10)
assert.Nil(t, info)
assert.Nil(t, err)
}
func TestFS_Open(t *testing.T) {
fs := FS{http.Dir("testdata/static")}
f, err := fs.Open("non-existent.js")
assert.Error(t, err)
assert.Nil(t, f)
f, err = fs.Open("main.html")
assert.NoError(t, err)
assert.IsType(t, File{}, f)
}