Skip to content

Commit 762100b

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

File tree

2 files changed

+39
-19
lines changed

2 files changed

+39
-19
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ class AzBatchServiceTest extends Specification {
745745
and:
746746
def POOL_ID = 'my-pool'
747747
def SAS = '123'
748-
def CONFIG = [storage: [sasToken: SAS]]
748+
def CONFIG = [storage: [sasToken: SAS], batch: [requireContainer: false]]
749749
def exec = Mock(AzBatchExecutor) {getConfig() >> new AzConfig(CONFIG) }
750750
AzBatchService azure = Spy(new AzBatchService(exec))
751751
and:

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

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,63 @@ class AzBatchTaskHandlerTest extends Specification {
2121

2222
def 'should validate config' () {
2323
when:
24-
def task = Mock(TaskRun) { getName() >> 'foo'; }
25-
def CONFIG = [batch: [requireContainer: false]]
26-
def exec = Mock(Executor) { getName() >> 'azurebatch' }
27-
processor.getExecutor() >> exec
24+
def task = Mock(TaskRun) {
25+
getName() >> 'foo'
26+
getProcessor() >> Mock(TaskProcessor) {
27+
getExecutor() >> Mock(Executor) { getName() >> 'azurebatch' }
28+
}
29+
}
30+
def CONFIG = [batch: [requireContainer: true]]
2831
and:
29-
new AzBatchTaskHandler(task: task)
30-
.validateConfiguration()
32+
new AzBatchTaskHandler(task: task, executor: Mock(AzBatchExecutor) {
33+
getConfig() >> new AzConfig(CONFIG)
34+
}).validateConfiguration()
3135
then:
3236
def e = thrown(ProcessUnrecoverableException)
3337
e.message.startsWith('No container image specified for process foo')
3438

35-
3639
when:
37-
task = Mock(TaskRun) { getName() >> 'foo'; getContainer() >> 'ubuntu' }
40+
task = Mock(TaskRun) {
41+
getName() >> 'foo'
42+
getContainer() >> 'ubuntu'
43+
}
3844
and:
39-
new AzBatchTaskHandler(task: task)
40-
.validateConfiguration()
45+
new AzBatchTaskHandler(task: task, executor: Mock(AzBatchExecutor) {
46+
getConfig() >> new AzConfig(CONFIG)
47+
}).validateConfiguration()
4148
then:
4249
noExceptionThrown()
4350
}
4451

4552
def 'should ignore missing container if disabled' () {
4653
when:
47-
def task = Mock(TaskRun) { getName() >> 'foo'; }
48-
def CONFIG = [batch: [requireContainer: false]]
54+
def task = Mock(TaskRun) {
55+
getName() >> 'foo'
56+
getContainer() >> null
57+
getProcessor() >> Mock(TaskProcessor) {
58+
getExecutor() >> Mock(Executor) { getName() >> 'azurebatch' }
59+
}
60+
}
61+
def CONFIG = [requireContainer: false]
4962
and:
50-
new AzBatchTaskHandler(task: task, config: new AzConfig(CONFIG))
51-
.validateConfiguration()
63+
new AzBatchTaskHandler(task: task, executor: Mock(AzBatchExecutor) {
64+
getConfig() >> new AzConfig(CONFIG)
65+
}).validateConfiguration()
5266
then:
5367
noExceptionThrown()
5468

55-
5669
when:
57-
task = Mock(TaskRun) { getName() >> 'foo'; getContainer() >> 'ubuntu' }
70+
task = Mock(TaskRun) {
71+
getName() >> 'foo'
72+
getContainer() >> 'ubuntu'
73+
getProcessor() >> Mock(TaskProcessor) {
74+
getExecutor() >> Mock(Executor) { getName() >> 'azurebatch' }
75+
}
76+
}
5877
and:
59-
new AzBatchTaskHandler(task: task)
60-
.validateConfiguration()
78+
new AzBatchTaskHandler(task: task, executor: Mock(AzBatchExecutor) {
79+
getConfig() >> new AzConfig([:])
80+
}).validateConfiguration()
6181
then:
6282
noExceptionThrown()
6383
}

0 commit comments

Comments
 (0)