Skip to content

Commit

Permalink
Update generator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jolelievre committed Oct 29, 2024
1 parent a589264 commit c7c71e3
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion tests/prestashop_docker/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,20 @@ def setUp(self):
CONTAINER_VERSION: $container_version
'''
)
self.fs.create_file(
'Dockerfile-branch.model',
contents='''
CONTAINER_VERSION: $container_version
RUN apt -y install git
RUN git clone -b $ps_version https://github.com/PrestaShop/PrestaShop.git /tmp/data-ps
'''
)

self.generator = Generator(
'/tmp/images',
open('Dockerfile.model').read(),
open('Dockerfile-nightly.model').read()
open('Dockerfile-nightly.model').read(),
open('Dockerfile-branch.model').read()
)

def test_create_directory(self):
Expand Down Expand Up @@ -92,6 +101,26 @@ def test_generate_nightly_image(self):
self.assertIn('PS_VERSION: nightly', content)
self.assertIn('CONTAINER_VERSION: 7.2-alpine', content)

def test_generate_branch_image(self):
dockerfile = '/tmp/images/9.0.x/8.1-alpine/Dockerfile'
self.assertFalse(path.exists(dockerfile))
self.generator.generate_image(
'9.0.x',
'8.1-alpine'
)
self.assertTrue(path.exists(dockerfile))

with open(dockerfile) as f:
content = f.read()
self.assertNotIn(
'PS_URL',
content
)
self.assertNotIn('PS_VERSION', content)
self.assertIn('CONTAINER_VERSION: 8.1-alpine', content)
self.assertIn('RUN apt -y install git', content)
self.assertIn('RUN git clone -b 9.0.x https://github.com/PrestaShop/PrestaShop.git /tmp/data-ps', content)

def test_generate_all(self):
files = (
'/tmp/images/7.0/7.3-apache/Dockerfile',
Expand Down

0 comments on commit c7c71e3

Please sign in to comment.