Skip to content

Commit

Permalink
Merge 100b55e into 165b4c6
Browse files Browse the repository at this point in the history
  • Loading branch information
Sinjo committed Mar 27, 2021
2 parents 165b4c6 + 100b55e commit c0fe32e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/prometheus/client/push.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class Push
attr_reader :job, :instance, :gateway, :path

def initialize(job, instance = nil, gateway = nil)
unless job
raise ArgumentError, "job cannot be nil"
end

@mutex = Mutex.new
@job = job
@instance = instance
Expand Down
6 changes: 6 additions & 0 deletions spec/prometheus/client/push_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
expect(push.gateway).to eql('http://pu.sh:1234')
end

it 'raises an ArgumentError if the job is not provided' do
expect do
Prometheus::Client::Push.new(nil)
end.to raise_error ArgumentError
end

it 'raises an ArgumentError if the given gateway URL is invalid' do
['inva.lid:1233', 'http://[invalid]'].each do |url|
expect do
Expand Down

0 comments on commit c0fe32e

Please sign in to comment.