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