MCPcopy Create free account
hub / github.com/dolthub/doltgresql / RunScript

Function RunScript

testing/go/framework.go:153–194  ·  view source on GitHub ↗

RunScript runs the given script.

(t *testing.T, script ScriptTest, normalizeRows bool)

Source from the content-addressed store, hash-verified

151
152// RunScript runs the given script.
153func RunScript(t *testing.T, script ScriptTest, normalizeRows bool) {
154 scriptDatabase := script.Database
155 if len(scriptDatabase) == 0 {
156 scriptDatabase = "postgres"
157 }
158
159 var ctx context.Context
160 var conn *Connection
161
162 if runOnPostgres {
163 ctx = context.Background()
164 pgxConn, err := pgx.Connect(ctx, fmt.Sprintf("postgres://postgres:password@127.0.0.1:%d/%s?sslmode=disable", 5432, scriptDatabase))
165 require.NoError(t, err)
166 conn = &Connection{
167 Default: pgxConn,
168 Current: pgxConn,
169 }
170 require.NoError(t, pgxConn.Ping(ctx))
171 defer func() {
172 conn.Close(ctx)
173 }()
174 } else {
175 var controller *svcs.Controller
176 if script.UseLocalFileSystem {
177 port, err := sql.GetEmptyPort()
178 require.NoError(t, err)
179 ctx, conn, controller = CreateServerLocalWithPort(t, scriptDatabase, port)
180 } else {
181 ctx, conn, controller = CreateServer(t, scriptDatabase)
182 }
183 defer func() {
184 conn.Close(ctx)
185 controller.Stop()
186 err := controller.WaitForStop()
187 require.NoError(t, err)
188 }()
189 }
190
191 t.Run(script.Name, func(t *testing.T) {
192 runScript(t, ctx, script, conn, normalizeRows)
193 })
194}
195
196// runScript runs the script given on the postgres connection provided
197func runScript(t *testing.T, ctx context.Context, script ScriptTest, conn *Connection, normalizeRows bool) {

Callers 1

runScriptsFunction · 0.70

Calls 7

CloseMethod · 0.95
ConnectMethod · 0.80
RunMethod · 0.80
CreateServerFunction · 0.70
runScriptFunction · 0.70
StopMethod · 0.45

Tested by

no test coverage detected