func (me *adapterTest) TestNewAdapter() { t := me.T() RegisterAdapter("test", func(ds *Dataset) Adapter { return NewDefaultAdapter(ds) }) assert.True(t, HasAdapter("test")) adapter := NewAdapter("test", From("test")) assert.NotNil(t, adapter) removeAdapter("test") adapter = NewAdapter("test", From("test")) assert.NotNil(t, adapter) }
func (me *databaseTest) TestPrepare() { t := me.T() mDb, err := sqlmock.New() assert.NoError(t, err) sqlmock.ExpectPrepare() db := New("mock", mDb) stmt, err := db.Prepare("SELECT * FROM test WHERE id = ?") assert.NoError(t, err) assert.NotNil(t, stmt) }
func (me *txDatabaseTest) TestFrom() { t := me.T() mDb, err := sqlmock.New() assert.NoError(t, err) sqlmock.ExpectBegin() sqlmock.ExpectCommit() db := New("mock", mDb) tx, err := db.Begin() assert.NoError(t, err) assert.NotNil(t, tx.From("test")) assert.NoError(t, tx.Commit()) }