1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/cli/compose/schema/schema_test.go
Daniel Nephin 65374488f9 Add v3.1 schema and support validating multiple version.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-01-26 11:33:15 -05:00

52 lines
907 B
Go

package schema
import (
"testing"
"github.com/stretchr/testify/assert"
)
type dict map[string]interface{}
func TestValidate(t *testing.T) {
config := dict{
"version": "3.0",
"services": dict{
"foo": dict{
"image": "busybox",
},
},
}
assert.NoError(t, Validate(config, "3.0"))
}
func TestValidateUndefinedTopLevelOption(t *testing.T) {
config := dict{
"version": "3.0",
"helicopters": dict{
"foo": dict{
"image": "busybox",
},
},
}
err := Validate(config, "3.0")
assert.Error(t, err)
assert.Contains(t, err.Error(), "Additional property helicopters is not allowed")
}
func TestValidateInvalidVersion(t *testing.T) {
config := dict{
"version": "2.1",
"services": dict{
"foo": dict{
"image": "busybox",
},
},
}
err := Validate(config, "2.1")
assert.Error(t, err)
assert.Contains(t, err.Error(), "unsupported Compose file version: 2.1")
}