mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-19 22:21:56 +03:00
36 lines
963 B
Go
36 lines
963 B
Go
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)
|
|
})
|
|
}
|
|
}
|