本文整理汇总了Golang中github.com/cloudwan/gohan/schema.ClearManager函数的典型用法代码示例。如果您正苦于以下问题:Golang ClearManager函数的具体用法?Golang ClearManager怎么用?Golang ClearManager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ClearManager函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: InitializeEnvironment
// InitializeEnvironment creates new transaction for the test
func (env *Environment) InitializeEnvironment() error {
var err error
_, file := filepath.Split(env.testFileName)
env.dbFile, err = ioutil.TempFile(os.TempDir(), file)
if err != nil {
return fmt.Errorf("Failed to create a temporary file in %s: %s", os.TempDir(), err.Error())
}
env.dbConnection, err = newDBConnection(env.dbFile.Name())
if err != nil {
return fmt.Errorf("Failed to connect to database: %s", err.Error())
}
env.Environment = gohan_otto.NewEnvironment(env.dbConnection, &middleware.FakeIdentity{}, 30*time.Second)
env.SetUp()
env.addTestingAPI()
script, err := env.VM.Compile(env.testFileName, env.testSource)
if err != nil {
return fmt.Errorf("Failed to compile the file '%s': %s", env.testFileName, err.Error())
}
env.VM.Run(script)
err = env.loadSchemas()
if err != nil {
schema.ClearManager()
return fmt.Errorf("Failed to load schema for '%s': %s", env.testFileName, err.Error())
}
err = db.InitDBWithSchemas("sqlite3", env.dbFile.Name(), true, false)
if err != nil {
schema.ClearManager()
return fmt.Errorf("Failed to init DB: %s", err.Error())
}
return nil
}
示例2: initBenchmarkDatabase
func initBenchmarkDatabase() error {
schema.ClearManager()
manager := schema.GetManager()
manager.LoadSchemasFromFiles("../etc/apps/example.yaml", "../etc/schema/gohan.json")
err := db.InitDBWithSchemas("mysql", "[email protected](localhost:3306)/gohan_test", false, false)
if err != nil {
return err
}
return nil
}
示例3: ClearEnvironment
// ClearEnvironment clears mock calls between tests and rollbacks test transaction
func (env *Environment) ClearEnvironment() {
for _, functionName := range env.mockedFunctions {
env.setToOtto(functionName, "requests", [][]otto.Value{})
env.setToOtto(functionName, "responses", []otto.Value{})
}
for _, tx := range env.dbTransactions {
tx.Close()
}
toDelete := env.dbFile.Name()
env.dbFile.Close()
os.Remove(toDelete)
schema.ClearManager()
}
示例4: TestOttoExtension
}
}
return nil
}
func TestOttoExtension(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Otto Extension Suite")
}
var _ = Describe("Suite set up and tear down", func() {
var _ = BeforeSuite(func() {
var err error
Expect(os.Chdir(configDir)).To(Succeed())
testDB, err = db.ConnectDB(dbType, dbFile, db.DefaultMaxOpenConn)
Expect(err).ToNot(HaveOccurred(), "Failed to connect database.")
manager := schema.GetManager()
config := util.GetConfig()
Expect(config.ReadConfig(configFile)).To(Succeed())
schemaFiles := config.GetStringList("schemas", nil)
Expect(schemaFiles).NotTo(BeNil())
Expect(manager.LoadSchemasFromFiles(schemaFiles...)).To(Succeed())
Expect(db.InitDBWithSchemas(dbType, dbFile, false, false)).To(Succeed())
})
var _ = AfterSuite(func() {
schema.ClearManager()
os.Remove(dbFile)
})
})