Beispiel #1
0
// NewSystem creates a database connection to access system metadata
func NewSystem(filename string) (System, error) {
	leaf, err := leaf.NewLeaf(filename)
	if err != nil {
		return nil, err
	}
	return &BoltSystemStore{leaf}, nil
}
Beispiel #2
0
// SetupSuite prepares the suite before any tests are ran
func (suite *SystemTestSuite) SetupSuite() {

	// Create temp directory
	suite.Dir, _ = ioutil.TempDir("", "datamodel.test")

	db, err := leaf.NewLeaf(path.Join(suite.Dir, "test.db"))
	if err != nil {
		suite.T().Log("Error creating database")
		suite.T().FailNow()
	}
	suite.DB = db
	suite.System = BoltSystemStore{db}
}
Beispiel #3
0
// SetupSuite prepares the suite before any tests are ran
func (suite *UserTestSuite) SetupSuite() {

	// Create temp directory
	suite.Dir, _ = ioutil.TempDir("", "datamodel.test")

	// Connect to database
	db, err := leaf.NewLeaf(path.Join(suite.Dir, "test.db"))
	if err != nil {
		suite.T().Log("Error creating database")
		suite.T().FailNow()
	}
	suite.DB = db

	// Create keyspace
	ks, err := db.GetOrCreateKeyspace(Users)
	suite.Nil(err)
	suite.KS = ks

	// Create user store
	suite.US = NewBoltUserStore(ks)
}