當前位置: 首頁>>代碼示例>>Golang>>正文


Golang schema.ClearManager函數代碼示例

本文整理匯總了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
}
開發者ID:masaki-saeki,項目名稱:gohan,代碼行數:36,代碼來源:environment.go

示例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
}
開發者ID:gitter-badger,項目名稱:gohan,代碼行數:10,代碼來源:server_test.go

示例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()
}
開發者ID:vozhyk-,項目名稱:gohan,代碼行數:15,代碼來源:environment.go

示例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)
	})
})
開發者ID:marcin-ptaszynski,項目名稱:gohan,代碼行數:30,代碼來源:otto_suite_test.go


注:本文中的github.com/cloudwan/gohan/schema.ClearManager函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。