forked from AppliedTrust/sweet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bindata_test.go
49 lines (43 loc) · 1.14 KB
/
bindata_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
package sweet
import (
"io/ioutil"
"os"
"strings"
"testing"
)
func TestBindata(t *testing.T) {
directories := []string{"tmpl", "static"}
files := map[string]bool{}
// finding all bindata source files
for _, dir := range directories {
dirFiles, err := ioutil.ReadDir(dir)
if err != nil {
t.Errorf("Can't find bindata source directory: %s", dir)
}
for _, f := range dirFiles {
files[dir+string(os.PathSeparator)+f.Name()] = true
}
}
// checking dashboard template file
filename := "tmpl/index.html"
if _, exists := files[filename]; !exists {
t.Errorf("Critical bindata source file %s is missing", filename)
}
asset, err := Asset(filename)
if err != nil {
t.Errorf("Bindata is missing a critical file: %s", filename)
}
if !strings.Contains(string(asset), "Sweet status dashboard") {
t.Errorf("%s is missing expected HTML meta tag", filename)
}
// checking each source file is present in bindata
for filename = range files {
asset, err := Asset(filename)
if err != nil {
t.Errorf("Bindata is missing a file: %s", filename)
}
if len(asset) < 1 {
t.Errorf("Zero-length bindata file: %s", filename)
}
}
}