github.com/rudderlabs/rudder-go-kit@v0.30.0/testhelper/docker/resource/mysql/mysql_test.go (about) 1 package mysql_test 2 3 import ( 4 "database/sql" 5 "testing" 6 7 "github.com/ory/dockertest/v3" 8 "github.com/stretchr/testify/require" 9 10 // _ "github.com/go-sql-driver/mysql" // mysql driver uses MPL-2.0 license 11 "github.com/rudderlabs/rudder-go-kit/bytesize" 12 "github.com/rudderlabs/rudder-go-kit/testhelper/docker/resource/mysql" 13 ) 14 15 func TestMySQL(t *testing.T) { 16 pool, err := dockertest.NewPool("") 17 require.NoError(t, err, "it should be able to create a docker pool") 18 mysqlResource, err := mysql.Setup(pool, t, mysql.WithShmSize(10*bytesize.MB), mysql.WithTag("8.2.0")) 19 require.NoError(t, err, "it should be able to create a mysql resource") 20 21 if true { 22 t.Skip("Skipping test due to mysql driver license restrictions") 23 } 24 db, err := sql.Open("mysql", mysqlResource.DBDsn) 25 require.NoError(t, err, "it should be able to open a mysql connection") 26 require.NoError(t, db.Ping(), "it should be able to ping mysql") 27 28 _, err = db.Exec("CREATE SCHEMA `TesT`") 29 require.NoError(t, err, "it should be able to create a schema") 30 _, err = db.Exec("CREATE TABLE `TesT`.`TeSt` (id INT, name VARCHAR(255))") 31 require.NoError(t, err, "it should be able to create a table") 32 row := db.QueryRow("SELECT count(`TesT`.`TeSt`.id) FROM `TesT`.`TeSt`") 33 var count int 34 require.NoError(t, row.Scan(&count), "it should be able to scan a row") 35 require.Equal(t, 0, count, "it should be able to scan a row") 36 }