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
Alejandra Ferreiro Vidal 79b79457f4 remove !#groovy header
2019-05-23 10:37:28 +02:00

43 lines
1.3 KiB
Groovy

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
import util.JenkinsStepRule
class DurationMeasureTest extends BasePiperTest {
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
@Rule
public RuleChain rules = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
.around(stepRule)
@Test
void testDurationMeasurement() throws Exception {
def bodyExecuted = false
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()
}
}