package source_test import ( "testing" "github.com/stretchr/testify/require" "github.com/neilotoole/sq/libsq/source" ) func TestIsSQL(t *testing.T) { testCases := []struct { loc string want bool }{ {loc: "/path/to/data.xlsx", want: false}, {loc: "relative/path/to/data.xlsx", want: false}, {loc: "./relative/path/to/data.xlsx", want: false}, {loc: "../relative/path/to/data.xlsx", want: false}, {loc: "https://path/to/data.xlsx", want: false}, {loc: "http://path/to/data.xlsx", want: false}, {loc: "sqlite3:///path/to/sqlite.db", want: true}, {loc: "sqlserver://sq:p_ssW0rd@localhost?database=sqtest", want: true}, {loc: "postgres://sq:p_ssW0rd@localhost/sqtest?sslmode=disable", want: true}, {loc: "mysql://sq:p_ssW0rd@tcp(localhost:3306)/sqtest", want: true}, } for _, tc := range testCases { tc := tc t.Run(tc.loc, func(t *testing.T) { got := source.IsSQLLocation(tc.loc) require.Equal(t, tc.want, got) }) } }