本文整理匯總了Golang中github.com/cloudwan/gohan/schema.Manager.Schema方法的典型用法代碼示例。如果您正苦於以下問題:Golang Manager.Schema方法的具體用法?Golang Manager.Schema怎麽用?Golang Manager.Schema使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudwan/gohan/schema.Manager
的用法示例。
在下文中一共展示了Manager.Schema方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
AfterEach(func() {
schema.ClearManager()
if os.Getenv("MYSQL_TEST") != "true" {
os.Remove(conn)
}
})
Describe("Base operations", func() {
var (
tx transaction.Transaction
)
BeforeEach(func() {
Expect(manager.LoadSchemaFromFile("../tests/test_abstract_schema.yaml")).To(Succeed())
Expect(manager.LoadSchemaFromFile("../tests/test_schema.yaml")).To(Succeed())
networkSchema, ok = manager.Schema("network")
Expect(ok).To(BeTrue())
_, ok = manager.Schema("subnet")
Expect(ok).To(BeTrue())
serverSchema, ok = manager.Schema("server")
Expect(ok).To(BeTrue())
network1 := map[string]interface{}{
"id": "networkRed",
"name": "NetworkRed",
"description": "A crimson network",
"tenant_id": "red",
"shared": false,
"route_targets": []string{"1000:10000", "2000:20000"},
"providor_networks": map[string]interface{}{"segmentation_id": 10, "segmentation_type": "vlan"}}
networkResource1, err = manager.LoadResource("network", network1)
示例2:
var _ = Describe("GohanDb", func() {
var (
manager *schema.Manager
s *schema.Schema
ok bool
fakeResources []map[string]interface{}
err error
r0, r1 *schema.Resource
)
var ()
BeforeEach(func() {
manager = schema.GetManager()
s, ok = manager.Schema("test")
Expect(ok).To(BeTrue())
fakeResources = []map[string]interface{}{
map[string]interface{}{"tenant_id": "t0", "test_string": "str0", "test_bool": false},
map[string]interface{}{"tenant_id": "t1", "test_string": "str1", "test_bool": true},
}
r0, err = schema.NewResource(s, fakeResources[0])
Expect(err).ToNot(HaveOccurred())
r1, err = schema.NewResource(s, fakeResources[1])
Expect(err).ToNot(HaveOccurred())
})
Describe("gohan_db_list", func() {
示例3:
"tenant_id": adminTenantID,
"providor_networks": map[string]interface{}{},
"route_targets": []interface{}{},
"shared": false,
}
subnet1 = map[string]interface{}{
"id": "test3",
"name": "Minas Tirith",
"tenant_id": adminTenantID,
"cidr": "10.10.0.0/16",
}
})
JustBeforeEach(func() {
var ok bool
currentSchema, ok = manager.Schema(schemaID)
Expect(ok).To(BeTrue())
path = currentSchema.GetPluralURL()
policy, role := manager.PolicyValidate(action, path, auth)
Expect(policy).NotTo(BeNil())
context["policy"] = policy
context["role"] = role
context["tenant_id"] = auth.TenantID()
context["tenant_name"] = auth.TenantName()
context["auth_token"] = auth.AuthToken()
context["catalog"] = auth.Catalog()
context["auth"] = auth
context["identity_service"] = &middleware.FakeIdentity{}