|
19 | 19 | from api.models import App |
20 | 20 | from scheduler import KubeException |
21 | 21 |
|
| 22 | +from api.exceptions import DeisException |
22 | 23 | from api.tests import adapter, mock_port, DeisTestCase |
23 | 24 | import requests_mock |
24 | 25 |
|
@@ -572,6 +573,37 @@ def test_get_private_registry_config_bad_registry_location(self, mock_requests): |
572 | 573 | self.assertEqual(name, None) |
573 | 574 | self.assertEqual(create, None) |
574 | 575 |
|
| 576 | + def test_build_env_vars(self, mock_requests): |
| 577 | + app = App.objects.create(owner=self.user) |
| 578 | + # Make sure an exception is raised when calling without a build available |
| 579 | + with self.assertRaises(DeisException): |
| 580 | + app._build_env_vars(app.release_set.latest()) |
| 581 | + data = {'image': 'autotest/example'} |
| 582 | + url = "/v2/apps/{app.id}/builds".format(**locals()) |
| 583 | + response = self.client.post(url, data) |
| 584 | + self.assertEqual(response.status_code, 201, response.data) |
| 585 | + self.assertEqual( |
| 586 | + app._build_env_vars(app.release_set.latest()), |
| 587 | + { |
| 588 | + 'DEIS_APP': app.id, |
| 589 | + 'WORKFLOW_RELEASE': 'v2', |
| 590 | + 'PORT': 5000 |
| 591 | + }) |
| 592 | + data['sha'] = 'abc1234' |
| 593 | + response = self.client.post(url, data) |
| 594 | + self.assertEqual(response.status_code, 201, response.data) |
| 595 | + self.assertEqual( |
| 596 | + app._build_env_vars(app.release_set.latest()), |
| 597 | + { |
| 598 | + 'DEIS_APP': app.id, |
| 599 | + 'WORKFLOW_RELEASE': 'v3', |
| 600 | + 'PORT': 5000, |
| 601 | + 'SLUG_URL': 'autotest/example', |
| 602 | + 'BUILDER_STORAGE': None, |
| 603 | + 'DEIS_MINIO_SERVICE_HOST': '127.0.0.1', |
| 604 | + 'DEIS_MINIO_SERVICE_PORT': 80 |
| 605 | + }) |
| 606 | + |
575 | 607 |
|
576 | 608 | FAKE_LOG_DATA = bytes(""" |
577 | 609 | 2013-08-15 12:41:25 [33454] [INFO] Starting gunicorn 17.5 |
|
0 commit comments