MCPcopy
hub / github.com/sqlc-dev/sqlc / TestReplay

Function TestReplay

internal/endtoend/endtoend_test.go:108–303  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

106}
107
108func TestReplay(t *testing.T) {
109 // Ensure that this environment variable is always set to true when running
110 // end-to-end tests
111 os.Setenv("SQLC_DUMMY_VALUE", "true")
112
113 // t.Parallel()
114 ctx := context.Background()
115
116 var mysqlURI, postgresURI string
117
118 // First, check environment variables
119 if uri := os.Getenv("POSTGRESQL_SERVER_URI"); uri != "" {
120 postgresURI = uri
121 }
122 if uri := os.Getenv("MYSQL_SERVER_URI"); uri != "" {
123 mysqlURI = uri
124 }
125
126 // Try Docker for any missing databases
127 if postgresURI == "" || mysqlURI == "" {
128 if err := docker.Installed(); err == nil {
129 if postgresURI == "" {
130 host, err := docker.StartPostgreSQLServer(ctx)
131 if err != nil {
132 t.Logf("docker postgresql startup failed: %s", err)
133 } else {
134 postgresURI = host
135 }
136 }
137 if mysqlURI == "" {
138 host, err := docker.StartMySQLServer(ctx)
139 if err != nil {
140 t.Logf("docker mysql startup failed: %s", err)
141 } else {
142 mysqlURI = host
143 }
144 }
145 }
146 }
147
148 // Try native installation for any missing databases (Linux only)
149 if postgresURI == "" || mysqlURI == "" {
150 if err := native.Supported(); err == nil {
151 if postgresURI == "" {
152 host, err := native.StartPostgreSQLServer(ctx)
153 if err != nil {
154 t.Logf("native postgresql startup failed: %s", err)
155 } else {
156 postgresURI = host
157 }
158 }
159 if mysqlURI == "" {
160 host, err := native.StartMySQLServer(ctx)
161 if err != nil {
162 t.Logf("native mysql startup failed: %s", err)
163 } else {
164 mysqlURI = host
165 }

Callers

nothing calls this directly

Calls 15

InstalledFunction · 0.92
StartPostgreSQLServerFunction · 0.92
StartMySQLServerFunction · 0.92
SupportedFunction · 0.92
StartPostgreSQLServerFunction · 0.92
StartMySQLServerFunction · 0.92
DiffFunction · 0.92
GenerateFunction · 0.92
VetFunction · 0.92
FindTestsFunction · 0.85
cmpDirectoryFunction · 0.85
stderrTransformerFunction · 0.85

Tested by

no test coverage detected