|
4 | 4 |
|
5 | 5 | describe Prometheus::Client::LabelSetValidator do |
6 | 6 | let(:expected_labels) { [] } |
7 | | - let(:validator) { Prometheus::Client::LabelSetValidator.new(expected_labels: expected_labels) } |
| 7 | + let(:additional_reserved_labels) { [] } |
| 8 | + let(:validator) do |
| 9 | + Prometheus::Client::LabelSetValidator.new(expected_labels: expected_labels, reserved_labels: additional_reserved_labels) |
| 10 | + end |
8 | 11 | let(:invalid) { Prometheus::Client::LabelSetValidator::InvalidLabelSetError } |
9 | 12 |
|
10 | 13 | describe '.new' do |
|
42 | 45 | end.to raise_exception(described_class::InvalidLabelError) |
43 | 46 | end |
44 | 47 |
|
45 | | - it 'raises ReservedLabelError if a label key is reserved' do |
46 | | - [:job, :instance, :pid].each do |label| |
47 | | - expect do |
48 | | - validator.validate_symbols!(label => 'value') |
49 | | - end.to raise_exception(described_class::ReservedLabelError) |
| 48 | + context "with only the base set of reserved labels" do |
| 49 | + it "doesn't raise ReservedLabelError for the additional reserved label" do |
| 50 | + expect { validator.validate_symbols!(additional: 'value') }. |
| 51 | + to_not raise_exception |
| 52 | + end |
| 53 | + |
| 54 | + it 'raises ReservedLabelError if a label key is reserved' do |
| 55 | + expect { validator.validate_symbols!(pid: 'value') }. |
| 56 | + to raise_exception(described_class::ReservedLabelError) |
| 57 | + end |
| 58 | + end |
| 59 | + |
| 60 | + context "with an additional reserved label" do |
| 61 | + let(:additional_reserved_labels) { [:additional] } |
| 62 | + |
| 63 | + it 'raises ReservedLabelError if a label key is reserved' do |
| 64 | + [:additional, :pid].each do |label| |
| 65 | + expect do |
| 66 | + validator.validate_symbols!(label => 'value') |
| 67 | + end.to raise_exception(described_class::ReservedLabelError) |
| 68 | + end |
50 | 69 | end |
51 | 70 | end |
52 | 71 | end |
|
0 commit comments