package csv_test import ( "testing" "github.com/stretchr/testify/require" "github.com/neilotoole/sq/testh" "github.com/neilotoole/sq/testh/sakila" ) func TestSmoke(t *testing.T) { t.Parallel() testCases := []string{sakila.CSVActor, sakila.TSVActor, sakila.CSVActorHTTP} for _, handle := range testCases { handle := handle t.Run(handle, func(t *testing.T) { t.Parallel() th := testh.New(t) src := th.Source(sakila.CSVActor) sink, err := th.QuerySQL(src, "SELECT * FROM data") require.NoError(t, err) require.Equal(t, len(sakila.TblActorCols()), len(sink.RecMeta)) require.Equal(t, sakila.TblActorCount, len(sink.Recs)) }) } } func TestQuerySQL_Count(t *testing.T) { t.Parallel() testCases := []string{sakila.CSVActor, sakila.TSVActor} for _, handle := range testCases { 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 data") require.NoError(t, err) require.Equal(t, sakila.TblActorCount, len(sink.Recs)) sink, err = th.QuerySQL(src, "SELECT COUNT(*) FROM data") require.NoError(t, err) count, ok := sink.Recs[0][0].(*int64) require.True(t, ok) require.Equal(t, int64(sakila.TblActorCount), *count) }) } }