Codebase list golang-github-gobuffalo-packr / 2a1f936e-920d-4165-8fc1-b806e46771a1/main v2 / deprecated_test.go
2a1f936e-920d-4165-8fc1-b806e46771a1/main

Tree @2a1f936e-920d-4165-8fc1-b806e46771a1/main (Download .tar.gz)

deprecated_test.go @2a1f936e-920d-4165-8fc1-b806e46771a1/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)
}