Пример #1
0
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
// 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
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)
}