2020-08-06 20:58:47 +03:00
|
|
|
package sakila_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-06-22 21:30:38 +03:00
|
|
|
"github.com/neilotoole/sq/testh/tutil"
|
|
|
|
|
2020-08-06 20:58:47 +03:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
|
|
"github.com/neilotoole/sq/testh"
|
|
|
|
"github.com/neilotoole/sq/testh/sakila"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TestSakila_SQL is a sanity check for Sakila SQL test sources.
|
2023-04-30 17:18:56 +03:00
|
|
|
func TestSakila_SQL(t *testing.T) { //nolint:tparallel
|
2020-08-06 20:58:47 +03:00
|
|
|
// Verify that the latest-version aliases are as expected
|
|
|
|
require.Equal(t, sakila.Pg, sakila.Pg12)
|
|
|
|
require.Equal(t, sakila.My, sakila.My8)
|
2023-04-08 21:09:27 +03:00
|
|
|
require.Equal(t, sakila.MS, sakila.MS19)
|
2020-08-06 20:58:47 +03:00
|
|
|
|
2020-08-09 17:40:46 +03:00
|
|
|
handles := sakila.SQLAll()
|
2020-08-06 20:58:47 +03:00
|
|
|
for _, handle := range handles {
|
|
|
|
handle := handle
|
|
|
|
t.Run(handle, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
th := testh.New(t)
|
|
|
|
src := th.Source(handle)
|
|
|
|
sink, err := th.QuerySQL(src, "SELECT * FROM actor")
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, sakila.TblActorCount, len(sink.Recs))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestSakila_XLSX is a sanity check for Sakila XLSX test sources.
|
|
|
|
func TestSakila_XLSX(t *testing.T) {
|
2023-06-22 21:30:38 +03:00
|
|
|
tutil.SkipWindows(t, "XLSX fails on windows pipeline (too slow)")
|
|
|
|
|
2020-08-09 00:23:30 +03:00
|
|
|
handles := []string{sakila.XLSXSubset}
|
|
|
|
// TODO: Add sakila.XLSX to handles when performance is reasonable
|
|
|
|
// enough not to break CI.
|
2020-08-06 20:58:47 +03:00
|
|
|
|
|
|
|
for _, handle := range handles {
|
|
|
|
handle := handle
|
|
|
|
|
2020-08-09 00:23:30 +03:00
|
|
|
t.Run(handle, func(t *testing.T) {
|
2020-08-06 20:58:47 +03:00
|
|
|
th := testh.New(t)
|
|
|
|
src := th.Source(handle)
|
2020-08-09 00:23:30 +03:00
|
|
|
|
2020-08-06 20:58:47 +03:00
|
|
|
sink, err := th.QuerySQL(src, "SELECT * FROM actor")
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, sakila.TblActorCount, len(sink.Recs))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestSakila_CSV is a sanity check for Sakila CSV/TSV test sources.
|
|
|
|
func TestSakila_CSV(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
handles := []string{sakila.CSVActor, sakila.CSVActorNoHeader, sakila.TSVActor, sakila.TSVActorNoHeader}
|
|
|
|
for _, handle := range handles {
|
|
|
|
handle := handle
|
|
|
|
t.Run(handle, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
th := testh.New(t)
|
|
|
|
src := th.Source(handle)
|
|
|
|
// Note table "data" instead of "actor", because CSV is monotable
|
|
|
|
sink, err := th.QuerySQL(src, "SELECT * FROM data")
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, sakila.TblActorCount, len(sink.Recs))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2020-12-30 21:57:58 +03:00
|
|
|
|
|
|
|
func TestSQLiteCloseError(t *testing.T) {
|
|
|
|
th := testh.New(t)
|
|
|
|
src := th.Source(sakila.CSVActor)
|
|
|
|
// Note table "data" instead of "actor", because CSV is monotable
|
|
|
|
sink, err := th.QuerySQL(src, "SELECT * FROM data")
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, sakila.TblActorCount, len(sink.Recs))
|
|
|
|
}
|