Skip to content

Commit 989e1ed

Browse files
committed
add testing setup
1 parent 92cd6db commit 989e1ed

File tree

4 files changed

+60
-5
lines changed

4 files changed

+60
-5
lines changed

.generator/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ WORKDIR /app
6868
COPY cli.py .
6969

7070
# Set the entrypoint for the container to run the script.
71-
ENTRYPOINT ["python3.13", "./cli.py"]
71+
ENTRYPOINT ["python3.13", "./cli.py"]

.generator/cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
import argparse
1616
import sys
1717

18-
def handle_configure(args):
18+
def handle_configure(dry_run=False):
1919
# TODO(https://github.com/googleapis/librarian/issues/466): Implement configure command.
2020
print("'configure' command executed.")
2121

22-
def handle_generate(args):
22+
def handle_generate(dry_run=False):
2323
# TODO(https://github.com/googleapis/librarian/issues/448): Implement generate command.
2424
print("'generate' command executed.")
2525

26-
def handle_build(args):
26+
def handle_build(dry_run=False):
2727
# TODO(https://github.com/googleapis/librarian/issues/450): Implement build command.
2828
print("'build' command executed.")
2929

@@ -47,4 +47,4 @@ def handle_build(args):
4747
sys.exit(1)
4848

4949
args = parser.parse_args()
50-
args.func(args)
50+
args.func(args)

.generator/test_cli.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from cli import handle_generate, handle_build, handle_configure
16+
17+
18+
def test_handle_configure_dry_run():
19+
handle_configure(dry_run=True)
20+
21+
def test_handle_generate_dry_run():
22+
handle_generate(dry_run=True)
23+
24+
def test_handle_build_dry_run():
25+
handle_build(dry_run=True)

.github/workflows/generator.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
on:
2+
pull_request:
3+
branches:
4+
- main
5+
name: generator
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
test_generator_cli:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
# Use a fetch-depth of 2
17+
# See https://github.com/googleapis/google-cloud-python/issues/12013
18+
# and https://github.com/actions/checkout#checkout-head.
19+
with:
20+
fetch-depth: 2
21+
- name: Setup Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.10"
25+
- name: Install pytest
26+
run: |
27+
python -m pip install pytest
28+
- name: Run generator_cli tests
29+
run: |
30+
pytest .generator/test_cli.py

0 commit comments

Comments
 (0)