Skip to content

Commit 2ddc878

Browse files
authored
Merge pull request #1751 from dolthub/jennifer/fix-test
[no-release-notes] fix show port test
2 parents 5b744f6 + 1109bff commit 2ddc878

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

testing/go/framework.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ import (
5353
// rather than starting a doltgres server.
5454
const runOnPostgres = false
5555

56+
// currentPort is a port number that is currently in use. It's for tests only.
57+
var currentPort = 5432
58+
5659
// ScriptTest defines a consistent structure for testing queries.
5760
type ScriptTest struct {
5861
// Name of the script.
@@ -161,6 +164,7 @@ func RunScript(t *testing.T, script ScriptTest, normalizeRows bool) {
161164
controller.Stop()
162165
err := controller.WaitForStop()
163166
require.NoError(t, err)
167+
currentPort = 5432
164168
}()
165169
}
166170

@@ -337,6 +341,7 @@ func init() {
337341
func CreateServer(t *testing.T, database string) (context.Context, *Connection, *svcs.Controller) {
338342
require.NotEmpty(t, database)
339343
port := GetUnusedPort(t)
344+
currentPort = port
340345
controller, err := dserver.RunInMemory(&servercfg.DoltgresConfig{
341346
ListenerConfig: &servercfg.DoltgresListenerConfig{
342347
PortNumber: &port,

testing/go/set_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package _go
1616

1717
import (
18+
"fmt"
1819
"testing"
1920

2021
"github.com/dolthub/go-mysql-server/sql"
@@ -5841,15 +5842,15 @@ var setStmts = []ScriptTest{
58415842
Assertions: []ScriptTestAssertion{
58425843
{
58435844
Query: "SHOW port",
5844-
Expected: []sql.Row{{int64(5432)}},
5845+
Expected: []sql.Row{{currentPort}},
58455846
},
58465847
{
58475848
Query: "SET port TO '5432'",
58485849
ExpectedErr: "is a read only variable",
58495850
},
58505851
{
58515852
Query: "SELECT current_setting('port')",
5852-
Expected: []sql.Row{{"5432"}},
5853+
Expected: []sql.Row{{fmt.Sprintf("%v", currentPort)}},
58535854
},
58545855
},
58555856
},

0 commit comments

Comments
 (0)