2018-03-13 10:31:01 +02:00
|
|
|
import org.junit.Before
|
2018-03-08 10:07:25 +02:00
|
|
|
import org.junit.Ignore
|
2017-07-11 15:12:03 +02:00
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Test
|
|
|
|
import org.junit.rules.ExpectedException
|
2018-01-16 10:33:13 +02:00
|
|
|
import org.junit.rules.RuleChain
|
2018-03-13 10:31:01 +02:00
|
|
|
import org.yaml.snakeyaml.parser.ParserException
|
2018-01-16 18:06:25 +02:00
|
|
|
|
2018-03-13 10:31:01 +02:00
|
|
|
import hudson.AbortException
|
2018-06-06 11:19:19 +02:00
|
|
|
import util.BasePiperTest
|
2018-09-04 11:32:54 +02:00
|
|
|
import util.JenkinsDockerExecuteRule
|
2018-01-16 10:33:13 +02:00
|
|
|
import util.JenkinsLoggingRule
|
2018-08-31 10:22:43 +02:00
|
|
|
import util.JenkinsReadYamlRule
|
2018-01-16 16:03:00 +02:00
|
|
|
import util.JenkinsShellCallRule
|
2018-02-28 14:12:03 +02:00
|
|
|
import util.JenkinsStepRule
|
2019-04-24 12:47:37 +02:00
|
|
|
import util.JenkinsWriteFileRule
|
2018-01-26 15:55:15 +02:00
|
|
|
import util.Rules
|
2018-01-16 10:33:13 +02:00
|
|
|
|
2019-12-04 14:24:23 +02:00
|
|
|
import static org.junit.Assert.assertThat
|
|
|
|
import static org.hamcrest.Matchers.containsString
|
|
|
|
import static org.hamcrest.Matchers.hasItem
|
|
|
|
|
2018-06-06 11:19:19 +02:00
|
|
|
public class MtaBuildTest extends BasePiperTest {
|
2018-02-21 13:48:14 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
|
2020-05-19 08:51:18 +02:00
|
|
|
private JenkinsReadYamlRule readYamlRule = new JenkinsReadYamlRule(this)
|
2017-07-11 15:12:03 +02:00
|
|
|
|
|
|
|
@Rule
|
2018-02-28 14:12:03 +02:00
|
|
|
public RuleChain ruleChain = Rules
|
|
|
|
.getCommonRules(this)
|
2019-01-22 10:25:42 +02:00
|
|
|
.around(stepRule)
|
2020-05-19 08:51:18 +02:00
|
|
|
.around(readYamlRule)
|
2019-12-06 08:48:20 +02:00
|
|
|
|
2019-12-04 14:24:23 +02:00
|
|
|
@Test
|
2020-05-19 08:51:18 +02:00
|
|
|
void testCallGoWrapper() {
|
2019-12-04 14:24:23 +02:00
|
|
|
|
2020-05-19 08:51:18 +02:00
|
|
|
def calledWithParameters,
|
|
|
|
calledWithStepName,
|
|
|
|
calledWithMetadata,
|
|
|
|
calledWithCredentials
|
2019-12-04 14:24:23 +02:00
|
|
|
|
2020-05-19 08:51:18 +02:00
|
|
|
helper.registerAllowedMethod(
|
|
|
|
'piperExecuteBin',
|
|
|
|
[Map, String, String, List],
|
|
|
|
{
|
|
|
|
params, stepName, metaData, creds ->
|
|
|
|
calledWithParameters = params
|
|
|
|
calledWithStepName = stepName
|
|
|
|
calledWithMetadata = metaData
|
|
|
|
calledWithCredentials = creds
|
|
|
|
}
|
|
|
|
)
|
2018-04-17 17:35:10 +02:00
|
|
|
|
2020-05-19 08:51:18 +02:00
|
|
|
stepRule.step.mtaBuild(script: nullScript, buildTarget: 'CF')
|
2018-02-05 17:45:24 +02:00
|
|
|
|
2020-05-19 08:51:18 +02:00
|
|
|
assert calledWithParameters.size() == 2
|
|
|
|
assert calledWithParameters.script == nullScript
|
|
|
|
assert calledWithParameters.buildTarget == 'CF'
|
2018-02-05 17:45:24 +02:00
|
|
|
|
2020-05-19 08:51:18 +02:00
|
|
|
assert calledWithStepName == 'mtaBuild'
|
|
|
|
assert calledWithMetadata == 'metadata/mtaBuild.yaml'
|
|
|
|
assert calledWithCredentials.isEmpty()
|
2018-03-12 17:50:32 +02:00
|
|
|
|
2019-04-24 12:47:37 +02:00
|
|
|
}
|
2017-07-11 15:12:03 +02:00
|
|
|
}
|