2017-06-23 11:05:07 +00:00
|
|
|
package check
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
yaml "gopkg.in/yaml.v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
const cfgDir = "../cfg/"
|
|
|
|
|
|
|
|
// validate that the files we're shipping are valid YAML
|
|
|
|
func TestYamlFiles(t *testing.T) {
|
2017-09-17 00:09:02 +00:00
|
|
|
// TODO: make this list dynamic
|
|
|
|
dirs := []string{"1.6/", "1.7/"}
|
|
|
|
|
|
|
|
for _, dir := range dirs {
|
|
|
|
dir = cfgDir + dir
|
|
|
|
|
|
|
|
files, err := ioutil.ReadDir(dir)
|
2017-06-23 11:05:07 +00:00
|
|
|
if err != nil {
|
2017-09-17 00:09:02 +00:00
|
|
|
t.Fatalf("error reading %s directory: %v", dir, err)
|
2017-06-23 11:05:07 +00:00
|
|
|
}
|
|
|
|
|
2017-09-17 00:09:02 +00:00
|
|
|
for _, file := range files {
|
2017-06-23 11:05:07 +00:00
|
|
|
|
2017-09-17 00:09:02 +00:00
|
|
|
fileName := file.Name()
|
|
|
|
in, err := ioutil.ReadFile(dir + fileName)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("error opening file %s: %v", fileName, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
c := new(Controls)
|
|
|
|
|
|
|
|
err = yaml.Unmarshal(in, c)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("failed to load YAML from %s: %v", fileName, err)
|
|
|
|
}
|
2017-06-23 11:05:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|