assets: added tests to make sure vcs and embedded data are in sync
License: MIT Signed-off-by: Henry <cryptix@riseup.net>
Henry committed
Jul 3, 2015 at 10:23 UTC
057dbaf791310fc5542ebc76c2b713671431ee65
1 file changed
+46
assets/assets_test.go
new
+46
@@ -0,0 +1,46 @@
1
+package assets
2
+
3
+import (
4
+ "bytes"
5
+ "io/ioutil"
6
+ "sync"
7
+ "testing"
8
+)
9
+
10
+// TestEmbeddedDocs makes sure we don't forget to regenerate after documentation change
11
+func TestEmbeddedDocs(t *testing.T) {
12
+ const wantCnt = 6
13
+ if len(initDocPaths) < wantCnt {
14
+ t.Fatalf("expected %d documents got %d", wantCnt, len(initDocPaths))
15
+ }
16
+
17
+ var wg sync.WaitGroup
18
+ for _, f := range initDocPaths {
19
+ wg.Add(1)
20
+ // compare asset
21
+ go func(f string) {
22
+ defer wg.Done()
23
+ // load data from filesystem (git)
24
+ vcsData, err := ioutil.ReadFile(f)
25
+ if err != nil {
26
+ t.Errorf("asset %s: could not read vcs file: %s", f, err)
27
+ return
28
+ }
29
+
30
+ // load data from emdedded source
31
+ embdData, err := Asset(f)
32
+ if err != nil {
33
+ t.Errorf("asset %s: could not read vcs file: %s", f, err)
34
+ return
35
+ }
36
+
37
+ if !bytes.Equal(vcsData, embdData) {
38
+ t.Errorf("asset %s: vcs and embedded data isnt equal", f)
39
+ return
40
+ }
41
+
42
+ t.Logf("checked %s", f)
43
+ }(f)
44
+ }
45
+ wg.Wait()
46
+}