Skip to content
This repository was archived by the owner on Oct 22, 2019. It is now read-only.

Commit 07cc7ec

Browse files
authored
Merge pull request #43 from buffcode/fix-invalid-bucket-name-tests
False positive tests for invalid histogram label name
2 parents 127aa91 + 97a4eb6 commit 07cc7ec

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/Prometheus/Histogram.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public function __construct(Adapter $adapter, $namespace, $name, $help, $labels
3939
);
4040
}
4141
}
42-
foreach ($buckets as $bucket) {
43-
if ($bucket == 'le') {
42+
foreach ($labels as $label) {
43+
if ($label === 'le') {
4444
throw new \InvalidArgumentException("Histogram cannot have a label named 'le'.");
4545
}
4646
}

tests/Test/Prometheus/AbstractHistogramTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ public function itShouldProvideDefaultBuckets()
374374
/**
375375
* @test
376376
* @expectedException \InvalidArgumentException
377+
* @expectedExceptionMessage Histogram buckets must be in increasing order
377378
*/
378379
public function itShouldThrowAnExceptionWhenTheBucketSizesAreNotIncreasing()
379380
{
@@ -383,6 +384,7 @@ public function itShouldThrowAnExceptionWhenTheBucketSizesAreNotIncreasing()
383384
/**
384385
* @test
385386
* @expectedException \InvalidArgumentException
387+
* @expectedExceptionMessage Histogram must have at least one bucket
386388
*/
387389
public function itShouldThrowAnExceptionWhenThereIsLessThanOneBucket()
388390
{
@@ -392,15 +394,17 @@ public function itShouldThrowAnExceptionWhenThereIsLessThanOneBucket()
392394
/**
393395
* @test
394396
* @expectedException \InvalidArgumentException
397+
* @expectedExceptionMessage Histogram cannot have a label named
395398
*/
396399
public function itShouldThrowAnExceptionWhenThereIsALabelNamedLe()
397400
{
398-
new Histogram($this->adapter, 'test', 'some_metric', 'this is for testing', array('le'), array());
401+
new Histogram($this->adapter, 'test', 'some_metric', 'this is for testing', array('le'), array(1));
399402
}
400403

401404
/**
402405
* @test
403406
* @expectedException \InvalidArgumentException
407+
* @expectedExceptionMessage Invalid metric name
404408
*/
405409
public function itShouldRejectInvalidMetricsNames()
406410
{
@@ -410,6 +414,7 @@ public function itShouldRejectInvalidMetricsNames()
410414
/**
411415
* @test
412416
* @expectedException \InvalidArgumentException
417+
* @expectedExceptionMessage Invalid label name
413418
*/
414419
public function itShouldRejectInvalidLabelNames()
415420
{

0 commit comments

Comments
 (0)