mirror of
https://github.com/gofiber/storage.git
synced 2025-10-16 21:51:22 +08:00
chore: extract ports to constants
This commit is contained in:
@@ -23,6 +23,8 @@ const (
|
|||||||
clickhouseUser string = "default"
|
clickhouseUser string = "default"
|
||||||
clickhousePass string = "password"
|
clickhousePass string = "password"
|
||||||
clickhouseDB string = "fiber"
|
clickhouseDB string = "fiber"
|
||||||
|
clickhouseHttpPort = "8123/tcp"
|
||||||
|
clickhouseSuccessCode = 200
|
||||||
)
|
)
|
||||||
|
|
||||||
func getTestConnection(t testing.TB, cfg Config) (*Storage, error) {
|
func getTestConnection(t testing.TB, cfg Config) (*Storage, error) {
|
||||||
@@ -42,9 +44,9 @@ func getTestConnection(t testing.TB, cfg Config) (*Storage, error) {
|
|||||||
clickhouse.WithDatabase(clickhouseDB),
|
clickhouse.WithDatabase(clickhouseDB),
|
||||||
testcontainers.WithWaitStrategy(
|
testcontainers.WithWaitStrategy(
|
||||||
wait.ForAll(
|
wait.ForAll(
|
||||||
wait.ForListeningPort("8123/tcp"),
|
wait.ForListeningPort(clickhouseHttpPort),
|
||||||
wait.NewHTTPStrategy("/").WithPort("8123/tcp").WithStatusCodeMatcher(func(status int) bool {
|
wait.NewHTTPStrategy("/").WithPort(clickhouseHttpPort).WithStatusCodeMatcher(func(status int) bool {
|
||||||
return status == 200
|
return status == clickhouseSuccessCode
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@@ -19,6 +19,8 @@ const (
|
|||||||
minioImageEnvVar string = "TEST_MINIO_IMAGE"
|
minioImageEnvVar string = "TEST_MINIO_IMAGE"
|
||||||
minioUser string = "minio-user"
|
minioUser string = "minio-user"
|
||||||
minioPass string = "minio-password"
|
minioPass string = "minio-password"
|
||||||
|
minioPort = "9000/tcp"
|
||||||
|
minioHealthPath = "/minio/health/live"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newTestStore(t testing.TB) (*Storage, error) {
|
func newTestStore(t testing.TB) (*Storage, error) {
|
||||||
@@ -36,8 +38,8 @@ func newTestStore(t testing.TB) (*Storage, error) {
|
|||||||
minio.WithUsername(minioUser),
|
minio.WithUsername(minioUser),
|
||||||
minio.WithPassword(minioPass),
|
minio.WithPassword(minioPass),
|
||||||
testcontainers.WithWaitStrategy(
|
testcontainers.WithWaitStrategy(
|
||||||
wait.ForListeningPort("9000/tcp"),
|
wait.ForListeningPort(minioPort),
|
||||||
wait.ForHTTP("/minio/health/live").WithPort("9000"),
|
wait.ForHTTP(minioHealthPath).WithPort(minioPort),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
testcontainers.CleanupContainer(t, c)
|
testcontainers.CleanupContainer(t, c)
|
||||||
|
@@ -18,6 +18,8 @@ const (
|
|||||||
mongoDBImageEnvVar string = "TEST_MONGODB_IMAGE"
|
mongoDBImageEnvVar string = "TEST_MONGODB_IMAGE"
|
||||||
mongoDBUser string = "mongo-user"
|
mongoDBUser string = "mongo-user"
|
||||||
mongoDBPass string = "mongo-password"
|
mongoDBPass string = "mongo-password"
|
||||||
|
mongoDBPort = "27017/tcp"
|
||||||
|
mongoDBReadyLog = "Waiting for connections"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newTestStore(t testing.TB) (*Storage, error) {
|
func newTestStore(t testing.TB) (*Storage, error) {
|
||||||
@@ -34,8 +36,8 @@ func newTestStore(t testing.TB) (*Storage, error) {
|
|||||||
ctx, img, mongodb.WithUsername(mongoDBUser), mongodb.WithPassword(mongoDBPass),
|
ctx, img, mongodb.WithUsername(mongoDBUser), mongodb.WithPassword(mongoDBPass),
|
||||||
testcontainers.WithWaitStrategy(
|
testcontainers.WithWaitStrategy(
|
||||||
wait.ForAll(
|
wait.ForAll(
|
||||||
wait.ForListeningPort("27017/tcp"),
|
wait.ForListeningPort(mongoDBPort),
|
||||||
wait.ForLog("Waiting for connections"),
|
wait.ForLog(mongoDBReadyLog),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@@ -13,6 +13,12 @@ import (
|
|||||||
"github.com/testcontainers/testcontainers-go/wait"
|
"github.com/testcontainers/testcontainers-go/wait"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
neo4jHttpPort = "7474/tcp"
|
||||||
|
neo4jBoltPort = "7687/tcp"
|
||||||
|
neo4jReadyLog = "Bolt enabled on"
|
||||||
|
)
|
||||||
|
|
||||||
var testStore *Storage
|
var testStore *Storage
|
||||||
|
|
||||||
// TestMain sets up and tears down the test container
|
// TestMain sets up and tears down the test container
|
||||||
@@ -25,9 +31,9 @@ func TestMain(m *testing.M) {
|
|||||||
neo4j.WithAdminPassword("pass#w*#d"),
|
neo4j.WithAdminPassword("pass#w*#d"),
|
||||||
testcontainers.WithWaitStrategy(
|
testcontainers.WithWaitStrategy(
|
||||||
wait.ForAll(
|
wait.ForAll(
|
||||||
wait.ForListeningPort("7474/tcp"),
|
wait.ForListeningPort(neo4jHttpPort),
|
||||||
wait.ForListeningPort("7687/tcp"),
|
wait.ForListeningPort(neo4jBoltPort),
|
||||||
wait.ForLog("Bolt enabled on"),
|
wait.ForLog(neo4jReadyLog),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user