Skip to content

Commit db932d6

Browse files
committed
test: add integration test case for invalid gen-build-spec arguments
1 parent 59880f0 commit db932d6

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

src/macaron/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def gen_build_spec(gen_build_spec_args: argparse.Namespace) -> int:
263263
try:
264264
purl = PackageURL.from_string(gen_build_spec_args.package_url)
265265
except ValueError as error:
266-
logger.error("Cannot parse purl %s. Error %s.", gen_build_spec_args.package_url, error)
266+
logger.error("Cannot parse purl %s. Error %s", gen_build_spec_args.package_url, error)
267267
return os.EX_USAGE
268268

269269
build_spec_content = gen_build_spec_str(
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Copyright (c) 2024 - 2025, Oracle and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
3+
4+
description: |
5+
Running macaron gen-build-spec with invalid arguments.
6+
7+
tags:
8+
- macaron-python-package
9+
- macaron-docker-image
10+
- macaron-gen-build-spec
11+
12+
steps:
13+
- name: Run macaron analyze on the remote repository.
14+
kind: analyze
15+
options:
16+
command_args:
17+
- --package-url
18+
- pkg:maven/io.github.behnazh-w.demo/example-maven-app@2.0?type=jar
19+
- -rp
20+
- https://github.com/behnazh-w/example-maven-app
21+
- name: Using a format that we don't support.
22+
kind: gen-build-spec
23+
options:
24+
command_args:
25+
- -purl
26+
- pkg:maven/io.github.behnazh-w.demo/example-maven-app@2.0?type=jar
27+
- --output-format
28+
- this-format-is-not-supported
29+
expect_fail: true
30+
- name: Generate the RC Buildspec for a PURL that we haven't analyzed.
31+
kind: gen-build-spec
32+
options:
33+
command_args:
34+
- -purl
35+
- pkg:maven/io.micronaut/micronaut-core@4.2.3
36+
- --output-format
37+
- rc-buildspec
38+
expect_fail: true
39+
- name: Generate the RC Buildspec for a PURL that doesn't have namespace information.
40+
kind: gen-build-spec
41+
options:
42+
command_args:
43+
- -purl
44+
- pkg:maven/io.micronaut@4.2.3
45+
- --output-format
46+
- rc-buildspec
47+
expect_fail: true
48+
- name: Generate the RC Buildspec for a PURL that doesn't have version information.
49+
kind: gen-build-spec
50+
options:
51+
command_args:
52+
- -purl
53+
- pkg:maven/io.micronaut/micronaut-core
54+
- --output-format
55+
- rc-buildspec
56+
expect_fail: true
57+
- name: Generate the RC Buildspec using a database that doesn't exist.
58+
kind: gen-build-spec
59+
options:
60+
database: output/some_database.db
61+
command_args:
62+
- -purl
63+
- pkg:maven/io.github.behnazh-w.demo/example-maven-app@2.0?type=jar
64+
- --output-format
65+
- rc-buildspec
66+
expect_fail: true
67+
- name: Generate the RC Buildspec using an invalid PURL.
68+
kind: gen-build-spec
69+
options:
70+
command_args:
71+
- -purl
72+
- invalid_purl
73+
- --output-format
74+
- rc-buildspec
75+
expect_fail: true

tests/integration/cases/micronaut-projects_micronaut-core/test.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ description: |
88
99
tags:
1010
- macaron-python-package
11+
- macaron-gen-build-spec
1112

1213
steps:
1314
- name: Run macaron analyze
@@ -31,12 +32,14 @@ steps:
3132
kind: policy_report
3233
result: output/policy_report.json
3334
expected: policy_report.json
34-
- name: Run build spec generation
35+
- name: Run Reproducible-central build spec generation
3536
kind: gen-build-spec
3637
options:
3738
command_args:
3839
- -purl
3940
- pkg:maven/io.micronaut/micronaut-core@4.2.3
41+
- --output-format
42+
- rc-buildspec
4043
- name: Compare Buildspec.
4144
kind: compare
4245
options:

0 commit comments

Comments
 (0)