Skip to content

Commit

Permalink
tests: Add manifest test for submodules
Browse files Browse the repository at this point in the history
Add a testcase to parse a manifest and validate the as_dict output.
Add an invalid manifest file for missing required submodule properties.

Signed-off-by: Pieter De Gendt <[email protected]>
  • Loading branch information
pdgendt committed Sep 23, 2024
1 parent 7308890 commit 6b6a516
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/manifests/invalid_submodule_no_path.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Submodule entries require a path
manifest:
remotes:
- name: remote1
url-base: https://example.com
projects:
- name: project1
remote: remote1
submodules:
- name: project2
68 changes: 68 additions & 0 deletions tests/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3176,6 +3176,74 @@ def setup_project(name, group_filter):
assert hasattr(m, '_legacy_group_filter_warned')


def test_submodule_manifest():
m = M('''\
projects:
- name: project1
url: url
- name: project2
url: url
submodules: true
- name: project3
url: url
submodules:
- path: path
- name: project4
url: url
submodules:
- path: path
name: subproject1
- name: project5
url: url
submodules:
- path: path
name: subproject1
- path: path
name: subproject2
- name: project6
url: url
submodules: false
''').as_dict()['manifest']

mp = m['projects'][0]
assert 'submodules' not in mp

mp = m['projects'][1]
assert 'submodules' in mp
assert isinstance(mp['submodules'], bool)
assert mp['submodules']

mp = m['projects'][2]
assert isinstance(mp['submodules'], list)
assert len(mp['submodules']) == 1
assert 'path' in mp['submodules'][0]
assert mp['submodules'][0]['path'] == 'path'
assert 'name' not in mp['submodules'][0]

mp = m['projects'][3]
assert isinstance(mp['submodules'], list)
assert len(mp['submodules']) == 1
assert 'path' in mp['submodules'][0]
assert mp['submodules'][0]['path'] == 'path'
assert 'name' in mp['submodules'][0]
assert mp['submodules'][0]['name'] == 'subproject1'

mp = m['projects'][4]
assert isinstance(mp['submodules'], list)
assert len(mp['submodules']) == 2
assert 'path' in mp['submodules'][0]
assert mp['submodules'][0]['path'] == 'path'
assert 'name' in mp['submodules'][0]
assert mp['submodules'][0]['name'] == 'subproject1'
assert 'path' in mp['submodules'][1]
assert mp['submodules'][1]['path'] == 'path'
assert 'name' in mp['submodules'][1]
assert mp['submodules'][1]['name'] == 'subproject2'

mp = m['projects'][5]
assert 'submodules' not in mp


#########################################
# Various invalid manifests

Expand Down

0 comments on commit 6b6a516

Please sign in to comment.