Skip to content

Commit

Permalink
fix test and add test for invalid json parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
spali committed Oct 7, 2024
1 parent 4327284 commit 32ad930
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ def collect(self, mocker, registry):
yield registry

def test_run_command(self):
result = metrics.run_command(command='echo {"foo": "bar"}')
assert result == {"foo": "bar"}
result = metrics.run_command(command='echo {"foo": "bar"}{"foo2": "bar2"}')
assert result == [{"foo": "bar"},{"foo2": "bar2"}]

def test_run_command_ignore_invalid_json(self):
result = metrics.run_command(command='echo {"foo": "bar"}{"foo2": ')
assert result == [{"foo": "bar"}]

def test_registry(self, registry):
result = metrics.create_metrics(registry=registry)._names_to_collectors
Expand Down

0 comments on commit 32ad930

Please sign in to comment.