Skip to content

Commit

Permalink
Merge pull request Jimdo#43 from buffcode/fix-invalid-bucket-name-tests
Browse files Browse the repository at this point in the history
False positive tests for invalid histogram label name
  • Loading branch information
bracki authored Jul 10, 2017
2 parents 127aa91 + 97a4eb6 commit 07cc7ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Prometheus/Histogram.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public function __construct(Adapter $adapter, $namespace, $name, $help, $labels
);
}
}
foreach ($buckets as $bucket) {
if ($bucket == 'le') {
foreach ($labels as $label) {
if ($label === 'le') {
throw new \InvalidArgumentException("Histogram cannot have a label named 'le'.");
}
}
Expand Down
7 changes: 6 additions & 1 deletion tests/Test/Prometheus/AbstractHistogramTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ public function itShouldProvideDefaultBuckets()
/**
* @test
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Histogram buckets must be in increasing order
*/
public function itShouldThrowAnExceptionWhenTheBucketSizesAreNotIncreasing()
{
Expand All @@ -383,6 +384,7 @@ public function itShouldThrowAnExceptionWhenTheBucketSizesAreNotIncreasing()
/**
* @test
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Histogram must have at least one bucket
*/
public function itShouldThrowAnExceptionWhenThereIsLessThanOneBucket()
{
Expand All @@ -392,15 +394,17 @@ public function itShouldThrowAnExceptionWhenThereIsLessThanOneBucket()
/**
* @test
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Histogram cannot have a label named
*/
public function itShouldThrowAnExceptionWhenThereIsALabelNamedLe()
{
new Histogram($this->adapter, 'test', 'some_metric', 'this is for testing', array('le'), array());
new Histogram($this->adapter, 'test', 'some_metric', 'this is for testing', array('le'), array(1));
}

/**
* @test
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Invalid metric name
*/
public function itShouldRejectInvalidMetricsNames()
{
Expand All @@ -410,6 +414,7 @@ public function itShouldRejectInvalidMetricsNames()
/**
* @test
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Invalid label name
*/
public function itShouldRejectInvalidLabelNames()
{
Expand Down

0 comments on commit 07cc7ec

Please sign in to comment.