Exemple #1
0
// setup initializes for each indivdual test.
func setup(t *testing.T) *cayley.Handle {
	tests.ResetLog()

	store, err := cayleyshelf.New(cfg.MustURL("MONGO_URI").String(), nil)
	if err != nil {
		t.Fatalf("\t%s\tShould be able to connect to the cayley graph : %s", tests.Failed, err)
	}

	return store
}
Exemple #2
0
// NewCayley adds support to a DB value for cayley based on a registered
// master cayley handle.
func (db *DB) NewCayley(context interface{}, name string) error {
	var masterDB mgoDB
	var exists bool
	masterMGO.RLock()
	{
		masterDB, exists = masterMGO.ses[name]
	}
	masterMGO.RUnlock()

	if !exists {
		return fmt.Errorf("Master sesssion %q does not exist", name)
	}

	ses := masterDB.ses.Copy()
	store, err := cayleykit.New("", ses)
	if err != nil {
		return err
	}

	db.graphHandle = store

	return nil
}