Skip to content

Commit

Permalink
Raise ArgumentError in push.rb if job is empty
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Sinjakli <chris@sinjakli.co.uk>
  • Loading branch information
Sinjo committed Mar 27, 2021
1 parent d177e66 commit 8f3e71a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/prometheus/client/push.rb
Expand Up @@ -23,6 +23,7 @@ class Push

def initialize(job:, instance: nil, gateway: DEFAULT_GATEWAY)
raise ArgumentError, "job cannot be nil" if job.nil?
raise ArgumentError, "job cannot be empty" if job.empty?

@mutex = Mutex.new
@job = job
Expand Down
6 changes: 6 additions & 0 deletions spec/prometheus/client/push_spec.rb
Expand Up @@ -30,6 +30,12 @@
end.to raise_error ArgumentError
end

it 'raises an ArgumentError if the job is empty' do
expect do
Prometheus::Client::Push.new(job: "")
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 8f3e71a

Please sign in to comment.