Skip to content

Commit

Permalink
Fixing test
Browse files Browse the repository at this point in the history
  • Loading branch information
waschndolos committed Jan 9, 2024
1 parent 8899091 commit d4b71c5
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ void shouldProduceMetricsWhenJobHasCoverageBuildAction() {
configurationUtils.when(ConfigurationUtils::getNamespace).thenReturn("foo");
configurationUtils.when(ConfigurationUtils::getSubSystem).thenReturn("bar");
jenkinsStatic.when(Jenkins::get).thenReturn(jenkins);
configurationStatic.when(PrometheusConfiguration::get).thenReturn(config);

Job jobUnderTest = mock(Job.class);
when(jobUnderTest.getFullName()).thenReturn("some/job");

Run lastBuild = mock(Run.class);
when(lastBuild.isBuilding()).thenReturn(false);
when(jobUnderTest.getLastBuild()).thenReturn(lastBuild);
Expand All @@ -129,10 +131,12 @@ void shouldProduceMetricsWhenJobHasCoverageBuildAction() {
when(config.getJobAttributeName()).thenReturn("jenkins_job");
when(config.isCollectCodeCoverage()).thenReturn(true);

configurationStatic.when(PrometheusConfiguration::get).thenReturn(config);

CodeCoverageCollector sut = new CodeCoverageCollector();

List<Collector.MetricFamilySamples> collect = sut.collect();
assertEquals(12, collect.size(), "12 metrics should have been collected");
assertEquals(20, collect.size(), "20 metrics should have been collected");
}
}
}

0 comments on commit d4b71c5

Please sign in to comment.