mirror of
https://github.com/mudler/LocalAI.git
synced 2026-09-17 08:50:57 -04:00
Starting a Postgres and a NATS container per spec cost roughly 48 minutes of startup across the 213 specs behind SetupInfra, which is why this suite was never wired into CI. Containers move to BeforeSuite and isolation comes from CREATE DATABASE, which the dbName argument already described. Assisted-by: Claude Opus 5 [claude-code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
package distributed_test
|
|
|
|
import (
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("Test database naming", Label("Distributed"), func() {
|
|
Describe("sanitizeDBName", func() {
|
|
It("lowercases and replaces characters Postgres will not accept unquoted", func() {
|
|
Expect(sanitizeDBName("LocalAI-Test.Suite")).To(Equal("localai_test_suite"))
|
|
})
|
|
|
|
It("truncates to fit the 63-byte identifier limit with room for a suffix", func() {
|
|
long := ""
|
|
for i := 0; i < 100; i++ {
|
|
long += "a"
|
|
}
|
|
Expect(len(sanitizeDBName(long))).To(BeNumerically("<=", 50))
|
|
})
|
|
|
|
It("never produces an empty name", func() {
|
|
Expect(sanitizeDBName("---")).ToNot(BeEmpty())
|
|
})
|
|
})
|
|
|
|
Describe("replaceDBName", func() {
|
|
It("swaps the database in a testcontainers DSN and keeps the query string", func() {
|
|
dsn := "postgres://test:test@127.0.0.1:32768/localai_suite?sslmode=disable"
|
|
Expect(replaceDBName(dsn, "spec_7")).To(Equal("postgres://test:test@127.0.0.1:32768/spec_7?sslmode=disable"))
|
|
})
|
|
})
|
|
})
|