コード例 #1
0
ファイル: init_test.go プロジェクト: carriercomm/lavabot
func init() {
	// Mock data
	env.Config = &env.Flags{
		APIVersion:       "v0",
		LogFormatterType: "text",
		ForceColors:      true,

		SessionDuration: 72,

		RedisAddress: "127.0.0.1:6379",

		NSQdAddress:    "127.0.0.1:4150",
		LookupdAddress: "127.0.0.1:4160",

		RethinkDBAddress:  "127.0.0.1:28015",
		RethinkDBKey:      "",
		RethinkDBDatabase: "test",
	}

	// Connect to the RethinkDB server
	rdbSession, err := gorethink.Connect(gorethink.ConnectOpts{
		Address: env.Config.RethinkDBAddress,
		AuthKey: env.Config.RethinkDBKey,
		MaxIdle: 10,
		Timeout: time.Second * 10,
	})
	if err != nil {
		panic("connecting to RethinkDB should not return an error, got " + err.Error())
	}

	// Clear the test database
	err = gorethink.DbDrop("test").Exec(rdbSession)
	if err != nil {
		fmt.Println("removing the test database should not return an error, got " + err.Error())
	}

	// Disconnect
	err = rdbSession.Close()
	if err != nil {
		panic("closing the RethinkDB session should not return an error, got " + err.Error())
	}

	// Prepare a new mux (initialize the API)
	mux := setup.PrepareMux(env.Config)
	if mux == nil {
		panic("returned mux was nil")
	}

	// Set up a new temporary HTTP test server
	server = httptest.NewServer(mux)
	if server == nil {
		panic("returned httptest server was nil")
	}
}
コード例 #2
0
ファイル: rethinkdb_adapter.go プロジェクト: jostyee/casgo
// Clear all relevant databases and/or tables
func (db *RethinkDBAdapter) Teardown() *CASServerError {
	_, err := r.
		DbDrop(db.dbName).
		Run(db.session)
	if err != nil {
		casError := &FailedToTeardownDatabaseError
		casError.err = &err
		return casError
	}

	return nil
}
コード例 #3
0
ファイル: persistence_test.go プロジェクト: plants/sesame
func (suite *UserStoreSuite) TearDownSuite() {
	_, err := r.DbDrop("test").Run(suite.store.conn)
	if err != nil {
		fmt.Println("dropping \"test\" failed. Do it by hand before re-running")
	}
}
コード例 #4
0
func Teardown() error {
	if err := r.Db(TestDatabase).TableDrop(TestTable).Exec(rethinkSession()); err != nil {
		return err
	}
	return r.DbDrop(TestDatabase).Exec(rethinkSession())
}
コード例 #5
0
func deleteHookStore(store *HookStore) error {
	return r.DbDrop(store.DatabaseName).Exec(store.Session)
}