Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hktudock committed Aug 1, 2022
1 parent 8e35c20 commit 003d56a
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions riptide_engine_docker/tests/unit/container_builder_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ def test_set_port(self):

# Test CLI build
expected_cli = self.expected_cli_base + [
'-e', EENV_ON_LINUX + '=1',
'--label', 'riptide=1',
'-p', '5678:1234',
'-p', '5432:9876',
'-e', EENV_ON_LINUX + '=1',
'--label', 'riptide=1',
IMAGE_NAME, COMMAND
]
actual_cli = self.fix.build_docker_cli()
Expand All @@ -312,6 +312,29 @@ def test_set_network(self):
actual_cli = self.fix.build_docker_cli()
self.assertListEqual(actual_cli, expected_cli)

def test_set_use_host_network(self):
self.fix.set_network('name')
self.fix.set_use_host_network(True)

# Test API build
self.expected_api_base.update({
'network_mode': 'host'
})
del self.expected_api_base['ports']
actual_api = self.fix.build_docker_api()
self.assertDictEqual(actual_api, self.expected_api_base)

# Test CLI build
expected_cli = self.expected_cli_base + [
'--network', 'host',
'-e', EENV_ON_LINUX + '=1',
'--label', 'riptide=1',
IMAGE_NAME, COMMAND
]

actual_cli = self.fix.build_docker_cli()
self.assertListEqual(actual_cli, expected_cli)

def test_set_name(self):
self.fix.set_name('blubbeldiblub')

Expand Down Expand Up @@ -673,6 +696,8 @@ def test_init_from_service_current_user(self, *args, **kwargs):

# Test CLI build
expected_cli = self.expected_cli_base + [
'-p', '5678:1234',
'-p', '5432:9876',
'--entrypoint', ENTRYPOINT_CONTAINER_PATH,
'-u', '0',
'-e', EENV_ON_LINUX + '=1',
Expand All @@ -681,17 +706,15 @@ def test_init_from_service_current_user(self, *args, **kwargs):
'-e', 'key1=value1',
'-e', 'key2=value2',
'-e', EENV_OVERLAY_TARGETS + '=',
'-e', EENV_COMMAND_LOG_PREFIX + 'name2=command2',
'-e', EENV_COMMAND_LOG_PREFIX + 'name1=command1',
'-e', EENV_COMMAND_LOG_PREFIX + 'name2=command2',
'-e', EENV_USER + '=9898',
'-e', EENV_GROUP + '=8989',
'-e', EENV_RUN_MAIN_CMD_AS_USER + '=yes',
'--label', RIPTIDE_DOCKER_LABEL_IS_RIPTIDE + '=1',
'--label', RIPTIDE_DOCKER_LABEL_PROJECT + '=PROJECTNAME',
'--label', RIPTIDE_DOCKER_LABEL_SERVICE + '=SERVICENAME',
'--label', RIPTIDE_DOCKER_LABEL_MAIN + '=0',
'-p', '5678:1234',
'-p', '5432:9876',
'--mount', f'type=bind,dst={ENTRYPOINT_CONTAINER_PATH},src={expected_entrypoint_host_path},ro=1',
'--mount', f'type=bind,dst=bind1,src=host1,ro=1',
'--mount', f'type=bind,dst=bind2,src=host2,ro=0',
Expand Down Expand Up @@ -1205,10 +1228,10 @@ def test_service_add_main_port(self, find_open_port_starting_at_mock: Mock):

# Test CLI build
expected_cli = self.expected_cli_base + [
'-p', '9876:4536',
'-e', EENV_ON_LINUX + '=1',
'--label', RIPTIDE_DOCKER_LABEL_IS_RIPTIDE + '=1',
'--label', RIPTIDE_DOCKER_LABEL_HTTP_PORT + '=9876',
'-p', '9876:4536',
IMAGE_NAME, COMMAND
]
actual_cli = self.fix.build_docker_cli()
Expand Down

0 comments on commit 003d56a

Please sign in to comment.