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

Function RunWireScripts

testing/go/wire_test.go:7722–7871  ·  view source on GitHub ↗

RunWireScripts runs the given collection of scripts.

(t *testing.T, scripts []WireScriptTest)

Source from the content-addressed store, hash-verified

7720
7721// RunWireScripts runs the given collection of scripts.
7722func RunWireScripts(t *testing.T, scripts []WireScriptTest) {
7723 // First, we'll run through the scripts to check for the Focus variable. If it's true, then append it to the new slice.
7724 focusScripts := make([]WireScriptTest, 0, len(scripts))
7725 for _, script := range scripts {
7726 if script.Focus {
7727 // If this is running in GitHub Actions, then we'll panic, because someone forgot to disable it before committing
7728 if _, ok := os.LookupEnv("GITHUB_ACTION"); ok {
7729 panic(fmt.Sprintf("The wire script `%s` has Focus set to `true`. GitHub Actions requires that "+
7730 "all tests are run, which Focus circumvents, leading to this error. Please disable Focus on "+
7731 "all tests.", script.Name))
7732 }
7733 focusScripts = append(focusScripts, script)
7734 }
7735 if script.ExternalServerPort != 0 {
7736 // Same as with Focus, we want to panic in a GitHub Action since this is only for local debugging
7737 if _, ok := os.LookupEnv("GITHUB_ACTION"); ok {
7738 panic(fmt.Sprintf("The wire script `%s` has ExternalServerPort set to `%d`. GitHub Actions "+
7739 "requires that all tests are run against an in-memory Doltgres server, which ExternalServerPort "+
7740 "circumvents, leading to this error. Please remove ExternalServerPort on all tests.",
7741 script.Name, script.ExternalServerPort))
7742 }
7743 }
7744 }
7745 // If we have scripts with Focus set, then we replace the normal script slice with the new slice.
7746 if len(focusScripts) > 0 {
7747 scripts = focusScripts
7748 }
7749
7750 for _, script := range scripts {
7751 t.Run(script.Name, func(t *testing.T) {
7752 if script.Skip {
7753 t.Skip()
7754 }
7755
7756 var rawConn *RawWireConnection
7757 if script.ExternalServerPort == 0 {
7758 scriptDatabase := script.Database
7759 if len(scriptDatabase) == 0 {
7760 scriptDatabase = "postgres"
7761 }
7762 port, err := sql.GetEmptyPort()
7763 require.NoError(t, err)
7764 ctx, conn, controller := CreateServerWithPort(t, scriptDatabase, port)
7765 defer func() {
7766 controller.Stop()
7767 err := controller.WaitForStop()
7768 require.NoError(t, err)
7769 }()
7770 for _, query := range script.SetUpScript {
7771 _, err = conn.Exec(ctx, query)
7772 require.NoError(t, err, "error running setup query: %s", query)
7773 }
7774 conn.Close(ctx)
7775 rawConn = NewRawWireConnection(t, "localhost", port, "", "", 10*time.Second)
7776 defer rawConn.Close()
7777 } else {
7778 rawConn = NewRawWireConnection(t, "localhost", script.ExternalServerPort, "", "", 10*time.Second)
7779 defer rawConn.Close()

Callers 3

TestIssuesWireFunction · 0.85
TestWireTypesSendingFunction · 0.85
TestWireTypesReceivingFunction · 0.85

Calls 13

CloseMethod · 0.95
SendMethod · 0.95
ReceiveMethod · 0.95
EmptyReceiveBufferMethod · 0.95
CreateServerWithPortFunction · 0.85
NewRawWireConnectionFunction · 0.85
IgnoreMessageParametersFunction · 0.85
RunMethod · 0.80
ExecMethod · 0.80
CloseMethod · 0.65
FailNowMethod · 0.65
StopMethod · 0.45

Tested by

no test coverage detected