Codebase list golang-github-gobuffalo-packr / 18b1cfa3-f412-4c81-ba77-622292e87804/main v2 / deprecated_test.go
18b1cfa3-f412-4c81-ba77-622292e87804/main

Tree @18b1cfa3-f412-4c81-ba77-622292e87804/main (Download .tar.gz)

deprecated_test.go @18b1cfa3-f412-4c81-ba77-622292e87804/mainraw · history · blame

package packr

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func Test_PackBytes(t *testing.T) {
	r := require.New(t)

	box := NewBox("my/box")
	name := "foo.txt"
	body := []byte("foo!!")
	PackBytes(box.Name, name, body)

	f, err := box.FindString(name)
	r.NoError(err)
	r.Equal(string(body), f)
}

func Test_PackBytesGzip(t *testing.T) {
	r := require.New(t)

	box := NewBox("my/box")
	name := "foo.txt"
	body := []byte("foo!!")
	PackBytesGzip(box.Name, name, body)

	f, err := box.FindString(name)
	r.NoError(err)
	r.Equal(string(body), f)
}

func Test_PackJSONBytes(t *testing.T) {
	r := require.New(t)

	box := NewBox("my/box")
	name := "foo.txt"
	body := "\"PGgxPnRlbXBsYXRlcy9tYWlsZXJzL2xheW91dC5odG1sPC9oMT4KCjwlPSB5aWVsZCAlPgo=\""
	PackJSONBytes(box.Name, name, body)

	f, err := box.FindString(name)
	r.NoError(err)
	r.Equal("<h1>templates/mailers/layout.html</h1>\n\n<%= yield %>\n", f)
}