Tests: use getter for worker choice strategy instance
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 15 Oct 2022 14:17:24 +0000 (16:17 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 15 Oct 2022 14:17:24 +0000 (16:17 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
tests/pools/selection-strategies/worker-choice-strategy-context.test.js

index 46ac017c223687891b0eccd438892ea1a22f6c51..3ce8b9fe040218f9b8e3be0b7a184b87737af0a6 100644 (file)
@@ -93,9 +93,9 @@ describe('Worker choice strategy context test suite', () => {
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.ROUND_ROBIN
     )
-    expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
-      RoundRobinWorkerChoiceStrategy
-    )
+    expect(
+      workerChoiceStrategyContext.getWorkerChoiceStrategy()
+    ).toBeInstanceOf(RoundRobinWorkerChoiceStrategy)
   })
 
   it('Verify that setWorkerChoiceStrategy() works with ROUND_ROBIN and dynamic pool', () => {
@@ -105,11 +105,11 @@ describe('Worker choice strategy context test suite', () => {
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.ROUND_ROBIN
     )
-    expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
-      DynamicPoolWorkerChoiceStrategy
-    )
     expect(
-      workerChoiceStrategyContext.workerChoiceStrategy.workerChoiceStrategy
+      workerChoiceStrategyContext.getWorkerChoiceStrategy()
+    ).toBeInstanceOf(DynamicPoolWorkerChoiceStrategy)
+    expect(
+      workerChoiceStrategyContext.getWorkerChoiceStrategy().workerChoiceStrategy
     ).toBeInstanceOf(RoundRobinWorkerChoiceStrategy)
   })
 
@@ -120,9 +120,9 @@ describe('Worker choice strategy context test suite', () => {
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.LESS_RECENTLY_USED
     )
-    expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
-      LessRecentlyUsedWorkerChoiceStrategy
-    )
+    expect(
+      workerChoiceStrategyContext.getWorkerChoiceStrategy()
+    ).toBeInstanceOf(LessRecentlyUsedWorkerChoiceStrategy)
   })
 
   it('Verify that setWorkerChoiceStrategy() works with LESS_RECENTLY_USED and dynamic pool', () => {
@@ -132,11 +132,11 @@ describe('Worker choice strategy context test suite', () => {
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.LESS_RECENTLY_USED
     )
-    expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
-      DynamicPoolWorkerChoiceStrategy
-    )
     expect(
-      workerChoiceStrategyContext.workerChoiceStrategy.workerChoiceStrategy
+      workerChoiceStrategyContext.getWorkerChoiceStrategy()
+    ).toBeInstanceOf(DynamicPoolWorkerChoiceStrategy)
+    expect(
+      workerChoiceStrategyContext.getWorkerChoiceStrategy().workerChoiceStrategy
     ).toBeInstanceOf(LessRecentlyUsedWorkerChoiceStrategy)
   })
 
@@ -147,9 +147,9 @@ describe('Worker choice strategy context test suite', () => {
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.FAIR_SHARE
     )
-    expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
-      FairShareWorkerChoiceStrategy
-    )
+    expect(
+      workerChoiceStrategyContext.getWorkerChoiceStrategy()
+    ).toBeInstanceOf(FairShareWorkerChoiceStrategy)
   })
 
   it('Verify that setWorkerChoiceStrategy() works with FAIR_SHARE and dynamic pool', () => {
@@ -159,11 +159,11 @@ describe('Worker choice strategy context test suite', () => {
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.FAIR_SHARE
     )
-    expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
-      DynamicPoolWorkerChoiceStrategy
-    )
     expect(
-      workerChoiceStrategyContext.workerChoiceStrategy.workerChoiceStrategy
+      workerChoiceStrategyContext.getWorkerChoiceStrategy()
+    ).toBeInstanceOf(DynamicPoolWorkerChoiceStrategy)
+    expect(
+      workerChoiceStrategyContext.getWorkerChoiceStrategy().workerChoiceStrategy
     ).toBeInstanceOf(FairShareWorkerChoiceStrategy)
   })
 
@@ -174,9 +174,9 @@ describe('Worker choice strategy context test suite', () => {
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
     )
-    expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
-      WeightedRoundRobinWorkerChoiceStrategy
-    )
+    expect(
+      workerChoiceStrategyContext.getWorkerChoiceStrategy()
+    ).toBeInstanceOf(WeightedRoundRobinWorkerChoiceStrategy)
   })
 
   it('Verify that setWorkerChoiceStrategy() works with WEIGHTED_ROUND_ROBIN and dynamic pool', () => {
@@ -186,11 +186,11 @@ describe('Worker choice strategy context test suite', () => {
     workerChoiceStrategyContext.setWorkerChoiceStrategy(
       WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
     )
-    expect(workerChoiceStrategyContext.workerChoiceStrategy).toBeInstanceOf(
-      DynamicPoolWorkerChoiceStrategy
-    )
     expect(
-      workerChoiceStrategyContext.workerChoiceStrategy.workerChoiceStrategy
+      workerChoiceStrategyContext.getWorkerChoiceStrategy()
+    ).toBeInstanceOf(DynamicPoolWorkerChoiceStrategy)
+    expect(
+      workerChoiceStrategyContext.getWorkerChoiceStrategy().workerChoiceStrategy
     ).toBeInstanceOf(WeightedRoundRobinWorkerChoiceStrategy)
   })
 })