@@ -30,7 +30,7 @@ def check_docker():
3030 return False , f"Docker check failed: { e } "
3131
3232
33- def start_mongodb_docker ():
33+ def start_mongodb_docker (version = "8.0" ):
3434 """Start MongoDB in Docker container"""
3535 print ("Checking Docker availability..." )
3636 docker_ok , docker_msg = check_docker ()
@@ -63,7 +63,7 @@ def start_mongodb_docker():
6363 )
6464
6565 # Start new container with authentication
66- print (" Starting new MongoDB 8.0 container with auth..." )
66+ print (f " Starting new MongoDB { version } container with auth..." )
6767 result = subprocess .run (
6868 [
6969 "docker" ,
@@ -79,7 +79,7 @@ def start_mongodb_docker():
7979 "MONGO_INITDB_ROOT_PASSWORD=secret" ,
8080 "-e" ,
8181 "MONGO_INITDB_DATABASE=test_db" ,
82- "mongo:8.0 " ,
82+ f "mongo:{ version } " ,
8383 ],
8484 capture_output = True ,
8585 text = True ,
@@ -220,19 +220,21 @@ def suggest_alternatives():
220220
221221def main ():
222222 """Main function"""
223- if len (sys .argv ) != 2 :
223+ if len (sys .argv ) < 2 or len ( sys . argv ) > 3 :
224224 print (
225- "Usage: python mongo_test_helper .py [start|stop|setup|status|alternatives|test]"
225+ "Usage: python run_test_server .py [start|stop|setup|status|alternatives|test] [version ]"
226226 )
227+ print ("Version examples: 7.0, 8.0 (default: 8.0)" )
227228 sys .exit (1 )
228229
229230 command = sys .argv [1 ]
231+ version = sys .argv [2 ] if len (sys .argv ) == 3 else "8.0"
230232
231233 if command == "start" :
232- if start_mongodb_docker ():
234+ if start_mongodb_docker (version ):
233235 if wait_for_mongodb ():
234236 setup_test_data ()
235- print ("\n ✅ MongoDB test instance is ready!" )
237+ print (f "\n ✅ MongoDB { version } test instance is ready!" )
236238 print ("Connection: mongodb://localhost:27017/test_db" )
237239 else :
238240 print ("❌ MongoDB failed to start properly" )
0 commit comments