-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassets_test.go
53 lines (45 loc) · 1.04 KB
/
assets_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
47
48
49
50
51
52
53
package assets
import (
"bytes"
"io/ioutil"
"sync"
"testing"
)
// TestEmbeddedDocs makes sure we don't forget to regenerate after documentation change
func TestEmbeddedDocs(t *testing.T) {
testNFiles(initDocPaths, 5, t, "documents")
}
func testNFiles(fs []string, wantCnt int, t *testing.T, ftype string) {
if len(fs) < wantCnt {
t.Fatalf("expected %d %s. got %d", wantCnt, ftype, len(fs))
}
var wg sync.WaitGroup
for _, f := range fs {
wg.Add(1)
// compare asset
go func(f string) {
defer wg.Done()
testOneFile(f, t)
}(f)
}
wg.Wait()
}
func testOneFile(f string, t *testing.T) {
// load data from filesystem (git)
vcsData, err := ioutil.ReadFile(f)
if err != nil {
t.Errorf("asset %s: could not read vcs file: %s", f, err)
return
}
// load data from emdedded source
embdData, err := Asset(f)
if err != nil {
t.Errorf("asset %s: could not read vcs file: %s", f, err)
return
}
if !bytes.Equal(vcsData, embdData) {
t.Errorf("asset %s: vcs and embedded data isnt equal", f)
return
}
t.Logf("checked %s", f)
}