Files
polaris/vendor/github.com/gobuffalo/packr/packr_test.go
Bobby Brennan 54a4f92695 Pack static assets into packr box for portability
copy config.yaml to docker image

enable external usage of dashboard package

gofmt

fix comment

use packr for assets

add gobuffalo/packr dependency

add dependencies

fix pointer issues

add output-file option
2019-04-18 18:25:16 +00:00

47 lines
1.0 KiB
Go

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)
}