Skip to content

Commit

Permalink
add test for sysctls
Browse files Browse the repository at this point in the history
  • Loading branch information
lemmi committed Mar 9, 2024
1 parent a20d0ee commit 1c741d7
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pytests/test_container_to_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,35 @@ async def test_runtime(self):
"busybox",
],
)

async def test_sysctl(self):
c = create_compose_mock()

cnt0 = get_minimal_container()
cnt1 = get_minimal_container()

cnt0["sysctls"] = [
"net.core.somaxconn=1024",
"net.ipv4.tcp_syncookies=0",
]
cnt1["sysctls"] = {
"net.core.somaxconn": 1024,
"net.ipv4.tcp_syncookies": 0,
}

args0 = await container_to_args(c, cnt0)
args1 = await container_to_args(c, cnt1)
self.assertEqual(
args0,
args1,
)

async def test_sysctl_wrong_type(self):
c = create_compose_mock()
cnt = get_minimal_container()

# check whether wrong types are correctly rejected
for wrong_type in [True, 0, 0.0, "wrong", ()]:
with self.assertRaises(TypeError):
cnt["sysctls"] = wrong_type
await container_to_args(c, cnt)

0 comments on commit 1c741d7

Please sign in to comment.