本文整理匯總了Golang中github.com/juju/juju/environs/config.Schema函數的典型用法代碼示例。如果您正苦於以下問題:Golang Schema函數的具體用法?Golang Schema怎麽用?Golang Schema使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Schema函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Schema
// Schema returns the configuration schema for an environment.
func (environProvider) Schema() environschema.Fields {
fields, err := config.Schema(configSchema)
if err != nil {
panic(err)
}
return fields
}
示例2: TestSchema
func (*ConfigSuite) TestSchema(c *gc.C) {
fields := providerInstance.Schema()
// Check that all the fields defined in environs/config
// are in the returned schema.
globalFields, err := config.Schema(nil)
c.Assert(err, gc.IsNil)
for name, field := range globalFields {
c.Check(fields[name], jc.DeepEquals, field)
}
}
示例3: TestSchemaWithExtraOverlap
func (s *ConfigSuite) TestSchemaWithExtraOverlap(c *gc.C) {
schema, err := config.Schema(environschema.Fields{
"type": environschema.Attr{
Description: "duplicate",
Type: environschema.Tstring,
},
})
c.Assert(err, gc.ErrorMatches, `config field "type" clashes with global config`)
c.Assert(schema, gc.IsNil)
}
示例4: TestSchemaNoExtra
func (s *ConfigSuite) TestSchemaNoExtra(c *gc.C) {
schema, err := config.Schema(nil)
c.Assert(err, gc.IsNil)
orig := make(environschema.Fields)
for name, field := range config.ConfigSchema {
orig[name] = field
}
c.Assert(schema, jc.DeepEquals, orig)
// Check that we actually returned a copy, not the original.
schema["foo"] = environschema.Attr{}
_, ok := orig["foo"]
c.Assert(ok, jc.IsFalse)
}
示例5: TestSchemaWithExtraFields
func (s *ConfigSuite) TestSchemaWithExtraFields(c *gc.C) {
extraField := environschema.Attr{
Description: "fooish",
Type: environschema.Tstring,
}
schema, err := config.Schema(environschema.Fields{
"foo": extraField,
})
c.Assert(err, gc.IsNil)
c.Assert(schema["foo"], gc.DeepEquals, extraField)
delete(schema, "foo")
orig := make(environschema.Fields)
for name, field := range config.ConfigSchema {
orig[name] = field
}
c.Assert(schema, jc.DeepEquals, orig)
}