Skip to content

Commit

Permalink
test properly usable_targets with different target types
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
  • Loading branch information
TomasTomecek committed Sep 11, 2018
1 parent 0b41288 commit 8e0ff10
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
7 changes: 7 additions & 0 deletions colin/core/result.py
Expand Up @@ -56,6 +56,13 @@ class CheckResults(object):
def __init__(self, results):
self.results = CachingIterable(results)

@property
def results_per_check(self):
results_per_check = {}
for r in self.results:
results_per_check[r.check_name] = r
return results_per_check

@property
def _dict_of_results(self):
"""
Expand Down
2 changes: 0 additions & 2 deletions rulesets/fedora.json
Expand Up @@ -62,9 +62,7 @@
},
{
"names": [
"cmd_or_entrypoint",
"help_file_or_readme",
"no_root",
"run_or_usage_label"
],
"additional_tags": [
Expand Down
3 changes: 2 additions & 1 deletion tests/data/Dockerfile
Expand Up @@ -10,7 +10,8 @@ LABEL name="${NAME}" \
com.redhat.component="colin-labels" \
description="The image contains labels which are used for testing colin functionality." \
io.k8s.description="The image contains labels which are used for testing colin functionality." \
run="docker run <application image>"
run="docker run <application image>" \
url="https://project.example.com/"

COPY ./files/usage /files/usage

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_labels.py
Expand Up @@ -65,7 +65,7 @@ def test_labels_in_image():
"run_or_usage_label": "PASS",
"release_label": "FAIL",
"architecture_label": "FAIL",
"url_label": "FAIL",
"url_label": "PASS",
"help_label": "FAIL",
"build-date_label": "FAIL",
"distribution-scope_label": "FAIL",
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/test_targets.py
Expand Up @@ -57,6 +57,7 @@ def ruleset():
},
{
"name": "url_label",
"usable_targets": ["image"]
},
{
"name": "build-date_label",
Expand Down Expand Up @@ -105,6 +106,7 @@ def ruleset():
def test_docker_image_target(ruleset):
results = colin.run(LABELS_IMAGE, "image", ruleset=ruleset, logging_level=10, pull=False)
assert results.ok
assert results.results_per_check["url_label"].ok


def test_dockertar_target(tmpdir, ruleset):
Expand All @@ -113,6 +115,7 @@ def test_dockertar_target(tmpdir, ruleset):
subprocess.check_call(cmd)
results = colin.run(str(tb), "dockertar", ruleset=ruleset, logging_level=10, pull=False)
assert results.ok
assert results.results_per_check["url_label"].ok


def test_ostree_target(ruleset):
Expand All @@ -128,3 +131,4 @@ def test_ostree_target(ruleset):
subprocess.check_call(cmd)
results = colin.run(skopeo_target, "ostree", ruleset=ruleset, logging_level=10, pull=False)
assert results.ok
assert results.results_per_check["url_label"].ok

0 comments on commit 8e0ff10

Please sign in to comment.