Example #1
0
// Ensure that a user can be persisted to the database.
func TestTx_SaveUser(t *testing.T) {
	db := NewTestDB()
	defer db.Close()

	testutil.Ok(t, db.Update(func(tx *Tx) error {
		testutil.Ok(t, tx.SaveUser(dbExampleUser))
		return nil
	}))

	testutil.Ok(t, db.View(func(tx *Tx) error {
		u, _ := tx.User("U100")
		testutil.Equals(t, dbExampleUser, u)
		return nil
	}))
}
Example #2
0
//  Ensue that a meta string can be persisted to the database.
func TestTx_SetMeta(t *testing.T) {
	db := NewTestDB()
	defer db.Close()

	key := "foo"
	val := "bar"

	testutil.Ok(t, db.Update(func(tx *Tx) error {
		testutil.Ok(t, tx.SetMeta(key, val))
		return nil
	}))

	testutil.Ok(t, db.View(func(tx *Tx) error {
		meta := tx.Meta(key)
		testutil.Equals(t, meta, val)
		return nil
	}))
}
Example #3
0
// Ensure that a database can be opened and closed.
func TestDB_Open(t *testing.T) {
	db := NewTestDB()
	testutil.Ok(t, db.Close())
}