1
0
mirror of https://github.com/rancher/os.git synced 2025-08-01 15:08:47 +00:00

Add unit test that covers entire configuration

This commit is contained in:
Josh Curl 2016-11-08 11:48:45 -08:00
parent ceaec960c4
commit 1f1c56d0ec
No known key found for this signature in database
GPG Key ID: 82B504B9BCCFA677

View File

@ -4,6 +4,9 @@ import (
"fmt"
"strings"
"testing"
yaml "github.com/cloudfoundry-incubator/candiedyaml"
"github.com/rancher/os/util"
)
func testValidate(t *testing.T, cfg []byte, contains string) {
@ -26,4 +29,14 @@ func TestValidate(t *testing.T) {
`), "")
testValidate(t, []byte("bad_key: {}"), "Additional property bad_key is not allowed")
testValidate(t, []byte("rancher: []"), "rancher: Invalid type. Expected: object, given: array")
var fullConfig map[string]interface{}
if err := util.ConvertIgnoreOmitEmpty(CloudConfig{}, &fullConfig); err != nil {
t.Fatal(err)
}
fullConfigBytes, err := yaml.Marshal(fullConfig)
if err != nil {
t.Fatal(err)
}
testValidate(t, fullConfigBytes, "")
}