Skip to content

Commit dd336ab

Browse files
committed
fixup tests some more
Signed-off-by: adamrtalbot <12817534+adamrtalbot@users.noreply.github.com>
1 parent 762100b commit dd336ab

File tree

2 files changed

+17
-27
lines changed

2 files changed

+17
-27
lines changed

plugins/nf-azure/src/main/nextflow/cloud/azure/batch/AzBatchTaskHandler.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class AzBatchTaskHandler extends TaskHandler implements FusionAwareTask {
7171
}
7272

7373
void validateConfiguration() {
74+
println "AZURE_BATCH_CONFIG: ${executor.config.batch()}"
7475
if (!task.container && executor.config.batch().requireContainer ) {
7576
throw new ProcessUnrecoverableException("No container image specified for process $task.name -- Either specify the container to use in the process definition or with 'process.container' value in your config. You can disable this behaviour setting `azure.batch.requireContainer=false` in the nextflow config file")
7677
}

plugins/nf-azure/src/test/nextflow/cloud/azure/batch/AzBatchTaskHandlerTest.groovy

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ class AzBatchTaskHandlerTest extends Specification {
2727
getExecutor() >> Mock(Executor) { getName() >> 'azurebatch' }
2828
}
2929
}
30-
def CONFIG = [batch: [requireContainer: true]]
3130
and:
3231
new AzBatchTaskHandler(task: task, executor: Mock(AzBatchExecutor) {
33-
getConfig() >> new AzConfig(CONFIG)
32+
getConfig() >> new AzConfig([:])
3433
}).validateConfiguration()
3534
then:
3635
def e = thrown(ProcessUnrecoverableException)
@@ -41,43 +40,33 @@ class AzBatchTaskHandlerTest extends Specification {
4140
getName() >> 'foo'
4241
getContainer() >> 'ubuntu'
4342
}
43+
def CONFIG = [batch: [requireContainer: true]]
4444
and:
4545
new AzBatchTaskHandler(task: task, executor: Mock(AzBatchExecutor) {
46-
getConfig() >> new AzConfig(CONFIG)
46+
getConfig() >> new AzConfig(CONFIG)
4747
}).validateConfiguration()
4848
then:
4949
noExceptionThrown()
5050
}
5151

5252
def 'should ignore missing container if disabled' () {
53-
when:
54-
def task = Mock(TaskRun) {
55-
getName() >> 'foo'
56-
getContainer() >> null
57-
getProcessor() >> Mock(TaskProcessor) {
58-
getExecutor() >> Mock(Executor) { getName() >> 'azurebatch' }
59-
}
53+
given:
54+
def task = Mock(TaskRun)
55+
task.getName() >> 'batch-task'
56+
task.getConfig() >> new TaskConfig()
57+
task.getProcessor() >> Mock(TaskProcessor) {
58+
getExecutor() >> Mock(Executor) { getName() >> 'azurebatch' }
6059
}
61-
def CONFIG = [requireContainer: false]
6260
and:
63-
new AzBatchTaskHandler(task: task, executor: Mock(AzBatchExecutor) {
64-
getConfig() >> new AzConfig(CONFIG)
65-
}).validateConfiguration()
66-
then:
67-
noExceptionThrown()
61+
def handler = Spy(AzBatchTaskHandler)
62+
handler.task = task
63+
handler.executor = Mock(AzBatchExecutor) {
64+
getConfig() >> new AzConfig([batch: [requireContainer: false]])
65+
}
6866

6967
when:
70-
task = Mock(TaskRun) {
71-
getName() >> 'foo'
72-
getContainer() >> 'ubuntu'
73-
getProcessor() >> Mock(TaskProcessor) {
74-
getExecutor() >> Mock(Executor) { getName() >> 'azurebatch' }
75-
}
76-
}
77-
and:
78-
new AzBatchTaskHandler(task: task, executor: Mock(AzBatchExecutor) {
79-
getConfig() >> new AzConfig([:])
80-
}).validateConfiguration()
68+
handler.validateConfiguration()
69+
8170
then:
8271
noExceptionThrown()
8372
}

0 commit comments

Comments
 (0)