Skip to content

Commit 72446b4

Browse files
janLoaanand
authored andcommitted
Add unittest for the Tmpfs Hostconfig option
Signed-off-by: Jan Losinski <[email protected]>
1 parent 9e94070 commit 72446b4

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

tests/unit/container_test.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,62 @@ def test_create_container_with_aliases(self):
10161016
}
10171017
}}'''))
10181018

1019+
def test_create_container_with_tmpfs_list(self):
1020+
1021+
self.client.create_container(
1022+
'busybox', 'true', host_config=self.client.create_host_config(
1023+
tmpfs=[
1024+
"/tmp",
1025+
"/mnt:size=3G,uid=100"
1026+
]
1027+
)
1028+
)
1029+
1030+
args = fake_request.call_args
1031+
self.assertEqual(args[0][1], url_prefix +
1032+
'containers/create')
1033+
expected_payload = self.base_create_payload()
1034+
expected_payload['HostConfig'] = self.client.create_host_config()
1035+
expected_payload['HostConfig']['Tmpfs'] = {
1036+
"/tmp": "",
1037+
"/mnt": "size=3G,uid=100"
1038+
}
1039+
self.assertEqual(json.loads(args[1]['data']), expected_payload)
1040+
self.assertEqual(args[1]['headers'],
1041+
{'Content-Type': 'application/json'})
1042+
self.assertEqual(
1043+
args[1]['timeout'],
1044+
DEFAULT_TIMEOUT_SECONDS
1045+
)
1046+
1047+
def test_create_container_with_tmpfs_dict(self):
1048+
1049+
self.client.create_container(
1050+
'busybox', 'true', host_config=self.client.create_host_config(
1051+
tmpfs={
1052+
"/tmp": "",
1053+
"/mnt": "size=3G,uid=100"
1054+
}
1055+
)
1056+
)
1057+
1058+
args = fake_request.call_args
1059+
self.assertEqual(args[0][1], url_prefix +
1060+
'containers/create')
1061+
expected_payload = self.base_create_payload()
1062+
expected_payload['HostConfig'] = self.client.create_host_config()
1063+
expected_payload['HostConfig']['Tmpfs'] = {
1064+
"/tmp": "",
1065+
"/mnt": "size=3G,uid=100"
1066+
}
1067+
self.assertEqual(json.loads(args[1]['data']), expected_payload)
1068+
self.assertEqual(args[1]['headers'],
1069+
{'Content-Type': 'application/json'})
1070+
self.assertEqual(
1071+
args[1]['timeout'],
1072+
DEFAULT_TIMEOUT_SECONDS
1073+
)
1074+
10191075

10201076
class ContainerTest(DockerClientTest):
10211077
def test_list_containers(self):

0 commit comments

Comments
 (0)