File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
src/test/java/com/iexec/core/worker Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -250,12 +250,35 @@ void shouldAddTaskIdToWorker() {
250250 }
251251
252252 @ Test
253- void shouldNotAddTaskIdToWorker () {
253+ void shouldNotAddTaskIdToWorkerSinceUnknownWorker () {
254254 when (workerRepository .findByWalletAddress (Mockito .anyString ())).thenReturn (Optional .empty ());
255255 Optional <Worker > addedWorker = workerService .addChainTaskIdToWorker ("task1" , "0x1a69b2eb604db8eba185df03ea4f5288dcbbd248" );
256256 assertThat (addedWorker ).isEmpty ();
257257 }
258258
259+ @ Test
260+ void shouldNotAddTaskIdToWorkerSinceCantAcceptMoreWorker () {
261+ String workerName = "worker1" ;
262+ String walletAddress = "0x1a69b2eb604db8eba185df03ea4f5288dcbbd248" ;
263+ Worker existingWorker = Worker .builder ()
264+ .id ("1" )
265+ .name (workerName )
266+ .walletAddress (walletAddress )
267+ .os ("Linux" )
268+ .cpu ("x86" )
269+ .cpuNb (3 )
270+ .maxNbTasks (2 )
271+ .participatingChainTaskIds (new ArrayList <>(Arrays .asList ("task1" , "task2" )))
272+ .computingChainTaskIds (new ArrayList <>(Arrays .asList ("task1" , "task2" )))
273+ .build ();
274+
275+ when (workerRepository .findByWalletAddress (walletAddress )).thenReturn (Optional .of (existingWorker ));
276+ when (workerRepository .save (existingWorker )).thenReturn (existingWorker );
277+
278+ Optional <Worker > addedWorker = workerService .addChainTaskIdToWorker ("task3" , walletAddress );
279+ assertThat (addedWorker ).isEmpty ();
280+ }
281+
259282 // getChainTaskIds
260283
261284 @ Test
You can’t perform that action at this time.
0 commit comments