snapshot of https://github.com/centrifugal/centrifugo.git (master, 2026-09-16; blobs > 131072B omitted)
This commit is contained in:
31
internal/controllers/config_test.go
Normal file
31
internal/controllers/config_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/centrifugal/centrifuge"
|
||||
)
|
||||
|
||||
// A table prefix reaches DDL unquoted, so one PostgreSQL can't parse has to be
|
||||
// caught at construction — otherwise it surfaces much later as a syntax error
|
||||
// naming a generated table rather than the setting behind it.
|
||||
func TestNewPostgresController_RejectsBadTablePrefix(t *testing.T) {
|
||||
node, err := centrifuge.New(centrifuge.Config{})
|
||||
if err != nil {
|
||||
t.Fatalf("centrifuge.New: %v", err)
|
||||
}
|
||||
t.Cleanup(func() { _ = node.Shutdown(t.Context()) })
|
||||
|
||||
// Rejected before any connection is attempted, so this needs no Postgres.
|
||||
_, err = NewPostgresController(node, PostgresControllerConfig{
|
||||
DSN: "postgres://test:test@localhost:5432/test",
|
||||
TablePrefix: "cf-prod",
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("expected an error for a prefix PostgreSQL cannot parse unquoted")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "table_prefix") {
|
||||
t.Fatalf("error should name the setting at fault, got: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user