Move tests to query package

This commit is contained in:
Asdine El Hrychy
2019-12-04 20:47:19 +01:00
parent 56abf30461
commit 5b51b1ac0c
14 changed files with 618 additions and 550 deletions

40
query/drop_test.go Normal file
View File

@@ -0,0 +1,40 @@
package query_test
import (
"testing"
"github.com/asdine/genji"
"github.com/asdine/genji/engine/memoryengine"
"github.com/stretchr/testify/require"
)
func TestDrop(t *testing.T) {
tests := []struct {
name string
query string
fails bool
}{
{"Drop table", "DROP TABLE test", false},
{"Drop table If not exists", "DROP TABLE IF EXISTS test", false},
{"Drop index", "DROP INDEX idx", false},
{"Drop index if exists", "DROP INDEX IF EXISTS idx", false},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
db, err := genji.New(memoryengine.NewEngine())
require.NoError(t, err)
defer db.Close()
err = db.Exec("CREATE TABLE test; CREATE INDEX idx ON test (foo)")
require.NoError(t, err)
err = db.Exec(test.query)
if test.fails {
require.Error(t, err)
return
}
require.NoError(t, err)
})
}
}