Skip to content

Commit

Permalink
Provide Unit Test For Copy Images Feature (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
shachar2000 authored Oct 8, 2024
1 parent 32c95ba commit dfb8c4b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test_copy_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# ------------------------------------------ Test intro ------------------------------------------ #
# The test verifies that the copy_images method in the ImageController class successfully copies a
# Docker image (python:3.8-slim-bullseye) to a new repository (ygalidan/test1). It then checks
# that the copied image can be pulled from Docker Hub, confirming the image was correctly copied
# and uploaded.
# ------------------------------------------ Test intro ------------------------------------------ #

from src.disko.image_collector import *
import os
import docker
docker_client = docker.from_env()

# Import image_controller.py to use any function
ctl1 = ImageController("")

# Get password from GitHub secret
password = os.getenv("DOCKERHUB_PASSWORD")

# Name of image fron Docker Hub
images = ["python:3.8-slim-bullseye"]

ctl1.copy_images(images, "ygalidan/test1", "3.8-slim-bullseye", "ygalidan", password)

# Test after use function 'copy_images' and can be performed pull from new registry the specific images
def test_copy_images():
docker_client.login("ygalidan", password)
pull = docker_client.images.pull("ygalidan/test1", "3.8-slim-bullseye")
assert pull is not None

0 comments on commit dfb8c4b

Please sign in to comment.