TT#83358 status: add test

* bin/ngcpcfg: SKIP_RESTORE_PERMS so we can skip that on tests
* scripts/status: use NGCPCTL_BASE and NGCPCTL_MAIN so it would work
  in test environment

Change-Id: I8ba80bbb2ea3adf1b8cc2a4229568a87f9508cbd
mr10.0
Victor Seva 6 years ago
parent 59fa4170c5
commit 24098da128

@ -23,6 +23,10 @@ ngcpcfg_update_perms() {
}
ngcpcfg_restore_perms() {
if ${SKIP_RESTORE_PERMS:-false} ; then
log_debug "skip restore-permissions"
return 0
fi
# Must be the last command in every 'ngcpcfg' call as git resets POSIX permissions!
trap '' ERR EXIT
log_debug "Restore permissions from .ngcpcfg_perms as git might reset them"

@ -53,7 +53,7 @@ check_local_state() {
cd "$NGCPCTL_MAIN"
log_info "Checking state of ngcpcfg:"
if ! [ -r /etc/ngcp-config/.git/HEAD ] ; then
if ! [ -r "${NGCPCTL_MAIN}/.git/HEAD" ] ; then
log_warn "ngcpcfg has not been initialised yet. Execute 'ngcpcfg initialise'."
exit 0
fi
@ -83,10 +83,10 @@ check_local_state() {
check_etc_state() {
log_debug "check_etc_state"
log_debug "cd /etc"
cd /etc
log_debug "cd ${NGCPCTL_BASE}"
cd "${NGCPCTL_BASE}"
log_info "Checking state of /etc files:"
log_info "Checking state of ${NGCPCTL_BASE} files:"
if is_git_clean ; then
log_info "OK: nothing to commit"
else

Binary file not shown.

@ -4,6 +4,7 @@ markers =
build
cmdline
get
status
mt_16391
tt_11776
tt_16316

@ -0,0 +1,28 @@
#!/usr/bin/env py.test-3
import os
import pytest
@pytest.mark.status
def test_status(ngcpcfgcli, tmpdir, gitrepo):
src = "basic-ngcp-config.tar.gz"
with gitrepo.from_archive(src):
cfg_dir = os.path.join(gitrepo.localpath, "ngcp-config")
out = ngcpcfgcli(
"status",
env={
# don't mess with perms
"SKIP_RESTORE_PERMS": "true",
"NGCPCTL_MAIN": cfg_dir,
# we just need a clean git repo
"NGCPCTL_BASE": cfg_dir,
},
)
# debug, only printed in logs in case of error
print("stdout:")
print(out.stdout.replace("\\n", "\n"))
print("stderr:")
print(out.stderr.replace("\\n", "\n"))
assert out.returncode == 0
Loading…
Cancel
Save