1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
sap-jenkins-library/test/groovy/DurationMeasureTest.groovy

43 lines
1.3 KiB
Groovy
Raw Normal View History

import com.sap.piper.analytics.InfluxData
import org.junit.Rule
import org.junit.Test
import util.BasePiperTest
import static org.hamcrest.Matchers.hasKey
import static org.hamcrest.Matchers.is
import static org.hamcrest.Matchers.not
import static org.junit.Assert.assertThat
import org.junit.rules.RuleChain
import util.Rules
import util.JenkinsReadYamlRule
2018-02-28 14:11:09 +02:00
import util.JenkinsStepRule
class DurationMeasureTest extends BasePiperTest {
2019-01-22 10:25:42 +02:00
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
@Rule
2018-02-28 14:11:09 +02:00
public RuleChain rules = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
2019-01-22 10:25:42 +02:00
.around(stepRule)
@Test
void testDurationMeasurement() throws Exception {
def bodyExecuted = false
2019-01-22 10:25:42 +02:00
stepRule.step.durationMeasure(script: nullScript, measurementName: 'test') {
bodyExecuted = true
}
// doesnt work
//assertThat(InfluxData.getInstance().getFields(), hasEntry('pipeline_data', hasEntry('test', is(anything()))))
assertThat(InfluxData.getInstance().getFields(), hasKey('pipeline_data'))
assertThat(InfluxData.getInstance().getFields().pipeline_data, hasKey('test'))
assertThat(InfluxData.getInstance().getFields().pipeline_data.test, is(not(null)))
assertThat(bodyExecuted, is(true))
assertJobStatusSuccess()
}
}