IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Преглед на файлове

Add test for build_volumes.

master
Stanislaw Adaszewski преди 4 години
родител
ревизия
a008f3e9fc
променени са 1 файла, в които са добавени 37 реда и са изтрити 1 реда
  1. +37
    -1
      tests/test_compose.py

+ 37
- 1
tests/test_compose.py Целия файл

@@ -1,6 +1,7 @@
from focker.compose import exec_hook, \
exec_prebuild, \
exec_postbuild
exec_postbuild, \
build_volumes
from tempfile import TemporaryDirectory
import os
import pytest
@@ -9,6 +10,11 @@ from focker.misc import focker_lock, \
focker_unlock
import inspect
import ast
import stat
from focker.zfs import zfs_find, \
zfs_mountpoint, \
zfs_parse_output
import subprocess
def test_exec_hook_01():
@@ -93,3 +99,33 @@ def test_exec_prebuild():
def test_exec_postbuild():
_test_simple_forward(exec_postbuild)
def test_build_volumes():
subprocess.check_output(['focker', 'volume', 'remove', '--force', 'test-build-volumes'])
err = False
try:
name, _ = zfs_find('test-build-volumes', focker_type='volume')
except:
err = True
assert err
spec = {
'test-build-volumes': {
'chown': '65534:65534',
'chmod': 0o123,
'zfs': {
'quota': '1G',
'readonly': 'on'
}
}
}
build_volumes(spec)
name, _ = zfs_find('test-build-volumes', focker_type='volume')
st = os.stat(zfs_mountpoint(name))
assert st.st_uid == 65534
assert st.st_gid == 65534
assert ('%o' % st.st_mode)[-3:] == '123'
zst = zfs_parse_output(['zfs', 'get', '-H', 'quota,readonly', name])
assert zst[0][2] == '1G'
assert zst[1][2] == 'on'
subprocess.check_output(['zfs', 'destroy', '-r', '-f', name])

Loading…
Отказ
Запис