@@ -1009,17 +1009,17 @@ func SetupTestDatabaseWithConfig(t *testing.T, ctx context.Context, dbConfig Dat
10091009 return bdbID , cleanup
10101010}
10111011
1012- // SetupTestDatabaseAndFactory creates a database from environment config and returns both bdbID, factory, and cleanup function
1012+ // SetupTestDatabaseAndFactory creates a database from environment config and returns both bdbID, factory, test mode config, and cleanup function
10131013// This is the recommended way to setup tests as it ensures the client factory connects to the newly created database
10141014//
10151015// If REDIS_ENDPOINTS_CONFIG_PATH is not set, it will use the Docker proxy setup (localhost:7000) instead of creating a new database.
10161016// This allows tests to work with either the real fault injector OR the Docker proxy setup.
10171017//
10181018// Usage:
10191019//
1020- // bdbID, factory, cleanup := SetupTestDatabaseAndFactory(t, ctx, "standalone")
1020+ // bdbID, factory, testMode, cleanup := SetupTestDatabaseAndFactory(t, ctx, "standalone")
10211021// defer cleanup()
1022- func SetupTestDatabaseAndFactory (t * testing.T , ctx context.Context , databaseName string ) (bdbID int , factory * ClientFactory , cleanup func ()) {
1022+ func SetupTestDatabaseAndFactory (t * testing.T , ctx context.Context , databaseName string ) (bdbID int , factory * ClientFactory , testMode * TestModeConfig , cleanup func ()) {
10231023 // Get environment config
10241024 envConfig , err := GetEnvConfig ()
10251025 if err != nil {
@@ -1038,12 +1038,15 @@ func SetupTestDatabaseAndFactory(t *testing.T, ctx context.Context, databaseName
10381038
10391039 factory = NewClientFactory (redisConfig )
10401040
1041+ // Get proxy mock test mode config
1042+ testMode = GetTestModeConfig ()
1043+
10411044 // No-op cleanup since we're not creating a database
10421045 cleanup = func () {
10431046 factory .DestroyAll ()
10441047 }
10451048
1046- return 0 , factory , cleanup
1049+ return 0 , factory , testMode , cleanup
10471050 }
10481051
10491052 // Get database config from environment
@@ -1108,26 +1111,29 @@ func SetupTestDatabaseAndFactory(t *testing.T, ctx context.Context, databaseName
11081111 // Create client factory with the actual config from fault injector
11091112 factory = NewClientFactory (redisConfig )
11101113
1114+ // Get real fault injector test mode config
1115+ testMode = GetTestModeConfig ()
1116+
11111117 // Combined cleanup function
11121118 cleanup = func () {
11131119 factory .DestroyAll ()
11141120 dbManager .Cleanup (ctx )
11151121 fiCleanup ()
11161122 }
11171123
1118- return bdbID , factory , cleanup
1124+ return bdbID , factory , testMode , cleanup
11191125}
11201126
1121- // SetupTestDatabaseAndFactoryWithConfig creates a database with custom config and returns both bdbID, factory, and cleanup function
1127+ // SetupTestDatabaseAndFactoryWithConfig creates a database with custom config and returns both bdbID, factory, test mode config, and cleanup function
11221128//
11231129// If REDIS_ENDPOINTS_CONFIG_PATH is not set, it will use the Docker proxy setup (localhost:7000) instead of creating a new database.
11241130// This allows tests to work with either the real fault injector OR the Docker proxy setup.
11251131//
11261132// Usage:
11271133//
1128- // bdbID, factory, cleanup := SetupTestDatabaseAndFactoryWithConfig(t, ctx, "standalone", dbConfig)
1134+ // bdbID, factory, testMode, cleanup := SetupTestDatabaseAndFactoryWithConfig(t, ctx, "standalone", dbConfig)
11291135// defer cleanup()
1130- func SetupTestDatabaseAndFactoryWithConfig (t * testing.T , ctx context.Context , databaseName string , dbConfig DatabaseConfig ) (bdbID int , factory * ClientFactory , cleanup func ()) {
1136+ func SetupTestDatabaseAndFactoryWithConfig (t * testing.T , ctx context.Context , databaseName string , dbConfig DatabaseConfig ) (bdbID int , factory * ClientFactory , testMode * TestModeConfig , cleanup func ()) {
11311137 // Get environment config to use as template for connection details
11321138 envConfig , err := GetEnvConfig ()
11331139 if err != nil {
@@ -1146,12 +1152,15 @@ func SetupTestDatabaseAndFactoryWithConfig(t *testing.T, ctx context.Context, da
11461152
11471153 factory = NewClientFactory (redisConfig )
11481154
1155+ // Get proxy mock test mode config
1156+ testMode = GetTestModeConfig ()
1157+
11491158 // No-op cleanup since we're not creating a database
11501159 cleanup = func () {
11511160 factory .DestroyAll ()
11521161 }
11531162
1154- return 0 , factory , cleanup
1163+ return 0 , factory , testMode , cleanup
11551164 }
11561165
11571166 // Get database config from environment
@@ -1210,12 +1219,15 @@ func SetupTestDatabaseAndFactoryWithConfig(t *testing.T, ctx context.Context, da
12101219 // Create client factory with the actual config from fault injector
12111220 factory = NewClientFactory (redisConfig )
12121221
1222+ // Get real fault injector test mode config
1223+ testMode = GetTestModeConfig ()
1224+
12131225 // Combined cleanup function
12141226 cleanup = func () {
12151227 factory .DestroyAll ()
12161228 dbManager .Cleanup (ctx )
12171229 fiCleanup ()
12181230 }
12191231
1220- return bdbID , factory , cleanup
1232+ return bdbID , factory , testMode , cleanup
12211233}
0 commit comments