package scopes import ( "fmt" tbase "testing" "git.sr.ht/~cco/go-scopes/common/testing" "git.sr.ht/~cco/go-scopes/storage/sql" _ "git.sr.ht/~cco/go-scopes/storage/sql/pgsql" _ "git.sr.ht/~cco/go-scopes/storage/sql/sqlite" "git.sr.ht/~cco/go-scopes/tests/etc" ) func TestSqlite(tb *tbase.T) { t := testing.SetUp(tb) cfg := etc.ConfigSqlite() db := sql.Open(cfg) // resetSqlite(db) DoTests(t, cfg, db) } func TestPgsql(tb *tbase.T) { t := testing.SetUp(tb) cfg := etc.ConfigPgsql() db := sql.Open(cfg) // resetPgsql(db) DoTests(t, cfg, db) } func DoTests(t *testing.T, cfg *sql.Cfg, db *sql.Storage) { t.Run("base", func(t *testing.T) { BaseTest(t, cfg, db) }) } func BaseTest(t *testing.T, cfg *sql.Cfg, db *sql.Storage) { fmt.Println(cfg.Connstr) } // SQL statements var drop_table = `drop table test` var insert = `insert into test (label) values ('Hello World'), ('Good Afternoon')` var query = `select label from test where id = $1` // database-specific SQL statements // note: ... integer ... primary key ... automatically fills row sequentially var sqlite_create_table = `create table test ( id integer not null primary key, label text)` var pgsql_create_table = `create table test ( id serial not null primary key, label text)`