forked from gobuffalo/packr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
packr_test.go
46 lines (39 loc) · 1.04 KB
/
packr_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
45
46
package packr
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/require"
)
var testBox = NewBox("./fixtures")
var virtualBox = NewBox("./virtual")
func init() {
PackBytes(virtualBox.Path, "a", []byte("a"))
PackBytes(virtualBox.Path, "b", []byte("b"))
PackBytes(virtualBox.Path, "c", []byte("c"))
PackBytes(virtualBox.Path, "d/a", []byte("d/a"))
}
func Test_PackBytes(t *testing.T) {
r := require.New(t)
PackBytes(testBox.Path, "foo", []byte("bar"))
s, err := testBox.FindString("foo")
r.NoError(err)
r.Equal("bar", s)
}
func Test_PackJSONBytes(t *testing.T) {
r := require.New(t)
b, err := json.Marshal([]byte("json bytes"))
r.NoError(err)
err = PackJSONBytes(testBox.Path, "the bytes", string(b))
r.NoError(err)
s, err := testBox.Find("the bytes")
r.NoError(err)
r.Equal([]byte("json bytes"), s)
}
func Test_PackBytesGzip(t *testing.T) {
r := require.New(t)
err := PackBytesGzip(testBox.Path, "gzip", []byte("gzip foobar"))
r.NoError(err)
s, err := testBox.FindString("gzip")
r.NoError(err)
r.Equal("gzip foobar", s)
}