Skip to content

Commit

Permalink
Add TestPgsqlServer_InvalidTraffic
Browse files Browse the repository at this point in the history
  • Loading branch information
ostafen committed Apr 15, 2024
1 parent fb4b707 commit bd9e237
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pkg/pgsql/server/pgsql_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"encoding/hex"
"fmt"
"math/rand"
"net/http"
"os"
"testing"
"time"
Expand Down Expand Up @@ -1180,3 +1181,33 @@ func TestPgsqlServer_ExtendedQueryPGMultiFieldsPreparedMultiInsertError(t *testi
_, err = db.Exec(context.Background(), fmt.Sprintf("INSERT INTO %s (id, amount, total, title, content, isPresent) VALUES (?, ?, ?, ?, ?, ?); INSERT INTO %s (id, amount, total, title, content, isPresent) VALUES (?, ?, ?, ?, ?, ?)", table, table), 1, 1000, 6000, "title 1", blobContent, true, 2, 2000, 12000, "title 2", blobContent2, true)
require.ErrorContains(t, err, errors.ErrMaxStmtNumberExceeded.Error())
}

func TestPgsqlServer_InvalidTraffic(t *testing.T) {
td := t.TempDir()

options := server.DefaultOptions().
WithDir(td).
WithPort(0).
WithPgsqlServer(true).
WithPgsqlServerPort(0).
WithMetricsServer(false).
WithWebServer(false)

srv := server.DefaultServer().WithOptions(options).(*server.ImmuServer)

err := srv.Initialize()
if err != nil {
panic(err)
}

go func() {
srv.Start()
}()

defer func() {
srv.Stop()
}()

_, err = http.Get(fmt.Sprintf("http://localhost:%d", srv.PgsqlSrv.GetPort()))
require.Error(t, err)
}

0 comments on commit bd9e237

Please sign in to comment.