Skip to content

Commit

Permalink
Added unit test for skopeo util, removed test action from make (that …
Browse files Browse the repository at this point in the history
…does not use container), added action to both build and run tests in test container
  • Loading branch information
sebastian-echeverria committed Jan 22, 2025
1 parent 3d2fe90 commit 0a7f3cd
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: make check-lint
- name: Check types
run: make check-typecheck
- name: Docker Build Action
run: make build-container
- name: Execute unit tests
- name: Build main and test containers
run: make build-containers
- name: Execute unit tests inside test container
run: make test-container
13 changes: 4 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,13 @@ qa: isort format lint typecheck
.PHONY: check
check: check-isort check-format check-lint check-typecheck

# Run unit tests with pytest
.PHONY: test
test:
poetry run pytest test

# -----------------------------------------------------------------------------
# Container actions.
# -----------------------------------------------------------------------------

# Build all containers.
.PHONY: containers
containers:
.PHONY: build-containers
build-containers:
bash build_containers.sh

# Run unit tests inside container
Expand All @@ -75,10 +70,10 @@ test-container:

# Build and run unit tests inside container
.PHONY: build-test-container
build-test-container: containers test-container
build-test-container: build-containers test-container

# -----------------------------------------------------------------------------
# All actions and checks equivalent to what the CI does.
# -----------------------------------------------------------------------------
.PHONY: ci
ci: clean check test
ci: clean check build-test-container
42 changes: 42 additions & 0 deletions test/util/test_skopeo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Vessel Diff Tool
#
# Copyright 2024 Carnegie Mellon University.
#
# NO WARRANTY. THIS CARNEGIE MELLON UNIVERSITY AND SOFTWARE ENGINEERING
# INSTITUTE MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON
# UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
# AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS
# FOR PURPOSE OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM
# USE OF THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT MAKE ANY
# WARRANTY OF ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK,
# OR COPYRIGHT INFRINGEMENT.
#
# Licensed under a MIT (SEI)-style license, please see license.txt
# or contact [email protected] for full terms.
#
# [DISTRIBUTION STATEMENT A] This material has been approved for public
# release and unlimited distribution. Please see Copyright notice
# for non-US Government use and distribution.
#
# This Software includes and/or makes use of Third-Party Software
# each subject to its own license.
#
# DM24-1321


from pathlib import Path

from vessel.utils.skopeo import skopeo_copy
from vessel.utils.uri import ImageURI


def test_skopeo_copy(tmp_path: Path):
"""Tests that method to copy image through skopeo works."""

# Sample image in Docker hub
test_image_name = "hello-world:latest"
test_image_uri = ImageURI(f"docker://{test_image_name}")

dest_path = skopeo_copy(test_image_uri, str(tmp_path))

assert dest_path == f"{tmp_path}/{test_image_name.replace(':', '.')}"
2 changes: 1 addition & 1 deletion vessel/utils/skopeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
logger = getLogger(__name__)


def skopeo_copy(image_uri: "ImageURI", output_path: str) -> str:
def skopeo_copy(image_uri: ImageURI, output_path: str) -> str:
"""Skopeo copies image to specific directory.
Uses skopeo copy to take images from image path and then
Expand Down

0 comments on commit 0a7f3cd

Please sign in to comment.