@@ -17,7 +17,7 @@ import (
1717 "github.com/sqlc-dev/sqlc/internal/cmd"
1818 "github.com/sqlc-dev/sqlc/internal/config"
1919 "github.com/sqlc-dev/sqlc/internal/opts"
20- "github.com/sqlc-dev/sqlc/internal/sqltest/local "
20+ "github.com/sqlc-dev/sqlc/internal/sqltest/docker "
2121)
2222
2323func lineEndings () cmp.Option {
@@ -112,6 +112,24 @@ func TestReplay(t *testing.T) {
112112 // t.Parallel()
113113 ctx := context .Background ()
114114
115+ var mysqlURI , postgresURI string
116+ if err := docker .Installed (); err == nil {
117+ {
118+ host , err := docker .StartPostgreSQLServer (ctx )
119+ if err != nil {
120+ t .Fatalf ("starting postgresql failed: %s" , err )
121+ }
122+ postgresURI = host
123+ }
124+ {
125+ host , err := docker .StartMySQLServer (ctx )
126+ if err != nil {
127+ t .Fatalf ("starting mysql failed: %s" , err )
128+ }
129+ mysqlURI = host
130+ }
131+ }
132+
115133 contexts := map [string ]textContext {
116134 "base" : {
117135 Mutate : func (t * testing.T , path string ) func (* config.Config ) { return func (c * config.Config ) {} },
@@ -124,13 +142,13 @@ func TestReplay(t *testing.T) {
124142 {
125143 Name : "postgres" ,
126144 Engine : config .EnginePostgreSQL ,
127- URI : local . PostgreSQLServer () ,
145+ URI : postgresURI ,
128146 },
129147
130148 {
131149 Name : "mysql" ,
132150 Engine : config .EngineMySQL ,
133- URI : local . MySQLServer () ,
151+ URI : mysqlURI ,
134152 },
135153 }
136154 for i := range c .SQL {
@@ -150,13 +168,8 @@ func TestReplay(t *testing.T) {
150168 }
151169 },
152170 Enabled : func () bool {
153- if len (os .Getenv ("POSTGRESQL_SERVER_URI" )) == 0 {
154- return false
155- }
156- if len (os .Getenv ("MYSQL_SERVER_URI" )) == 0 {
157- return false
158- }
159- return true
171+ err := docker .Installed ()
172+ return err == nil
160173 },
161174 },
162175 }
0 commit comments