~evanj/embed

ref: 2cde7dae7bfa1d6669bbeed78660201bd2a2f167 embed/embed_test.go -rw-r--r-- 855 bytes
2cde7daeEvan M Jones Clean(embed_test.go): Ensure directory is made for test files in 1 year, 8 months ago
                                                                                
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
package main

import (
	"io/ioutil"
	"testing"

	"git.sr.ht/~evanj/embed/embedded/binary"
	"git.sr.ht/~evanj/embed/embedded/plaintext"
	"github.com/bmizerany/assert"
)

//go:generate go build
//go:generate mkdir -p static/bin
//go:generate cp embed static/bin

func TestBasic(t *testing.T) {
	str, ok := plaintext.Get("../../static/t/hello.txt")
	assert.Equal(t, true, ok)
	assert.Equal(t, "here we go\n", str)
}

func TestWeird(t *testing.T) {
	f, err := ioutil.ReadFile("static/t/weird.txt")
	assert.Equal(t, nil, err)
	str, ok := plaintext.Get("../../static/t/weird.txt")
	assert.Equal(t, true, ok)
	assert.Equal(t, string(f), str)
}

func TestBinary(t *testing.T) {
	f, err := ioutil.ReadFile("static/bin/embed")
	assert.Equal(t, nil, err)
	str, ok := binary.Get("../../static/bin/embed")
	assert.Equal(t, true, ok)
	assert.Equal(t, string(f), str)
}