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:
parent
ceaec960c4
commit
1f1c56d0ec
@ -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, "")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user