-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
97 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
control-plane/roles/gardener/test/gardener_soil_project_template_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import unittest | ||
import sys | ||
import yaml | ||
|
||
from test import FILTER_PLUGINS_PATH,read_template_file,read_mock_file | ||
|
||
from ansible.template import Templar | ||
|
||
sys.path.insert(0, FILTER_PLUGINS_PATH) | ||
|
||
class GardenerSoilProjectTemplate(unittest.TestCase): | ||
def test_gardener_soil_project_template(self): | ||
t = read_template_file("gardener-soil-project.yaml.j2") | ||
|
||
templar = Templar(loader=None, variables={ | ||
"gardener_soil_name": "test-project", | ||
"gardener_soil_project_owner_name": "test-owner", | ||
"gardener_soil_project_members": [ | ||
{ | ||
"name": "test-member1", | ||
"role": "viewer", | ||
}, | ||
{ | ||
"name": "test-member2", | ||
"role": "admin", | ||
"roles": [ | ||
"editor", | ||
"owner", | ||
], | ||
}, | ||
], | ||
}) | ||
|
||
res = templar.template(t) | ||
expected = read_mock_file("gardener_soil_project.yaml") | ||
|
||
self.maxDiff = None | ||
self.assertDictEqual(yaml.safe_load(expected), yaml.safe_load(res)) |
40 changes: 40 additions & 0 deletions
40
control-plane/roles/gardener/test/mock/gardener_soil_project.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apiVersion: core.gardener.cloud/v1beta1 | ||
kind: Project | ||
metadata: | ||
name: test-project | ||
labels: | ||
gardener.cloud/role: project | ||
project.gardener.cloud/name: test-project | ||
spec: | ||
namespace: garden | ||
tolerations: | ||
defaults: | ||
- key: seed.gardener.cloud/protected | ||
- key: seed.gardener.cloud/invisible | ||
- key: seed.gardener.cloud/disable-capacity-reservation | ||
whitelist: | ||
- key: seed.gardener.cloud/protected | ||
- key: seed.gardener.cloud/invisible | ||
- key: seed.gardener.cloud/disable-capacity-reservation | ||
owner: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: User | ||
name: test-owner | ||
members: | ||
- apiGroup: rbac.authorization.k8s.io | ||
kind: User | ||
name: test-owner | ||
role: admin | ||
roles: | ||
- owner | ||
- apiGroup: rbac.authorization.k8s.io | ||
kind: User | ||
name: test-member1 | ||
role: viewer | ||
- apiGroup: rbac.authorization.k8s.io | ||
kind: User | ||
name: test-member2 | ||
role: admin | ||
roles: | ||
- editor | ||
- owner |