-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathresources_test.go
46 lines (37 loc) · 938 Bytes
/
resources_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 main
import (
"bytes"
"os"
"path/filepath"
"testing"
"github.com/forensicanalysis/go-resources/testdata/generated"
)
//go:generate go build -o testdata/resources .
//go:generate testdata/resources -package generated -output testdata/generated/store_prod.go testdata/*.txt testdata/*.sql testdata/*.bin
func TestGenerated(t *testing.T) {
t.Parallel()
for _, tt := range []struct {
name string
}{
{name: "test.txt"},
{name: "patrick.txt"},
{name: "query.sql"},
{name: "123.bin"},
{name: "12.bin"},
} {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
content, ok := generated.FS["/testdata/"+tt.name]
if !ok {
t.Fatalf("expected no error opening file")
}
data, err := os.ReadFile(filepath.Join("testdata", tt.name))
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(content, data) {
t.Errorf("expected to find snippet '%x', got: '%x'", data, content)
}
})
}
}