mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-09-03 20:21:29 +00:00
API: output for autoupdate
This commit provides a minimal output to be displayed when the --quiet flag is used for this command: - swupd autoupdate Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This commit is contained in:
committed by
Castulo J. Martinez
parent
b62aae3c8c
commit
f3bb9765da
+2
-2
@@ -161,7 +161,7 @@ enum swupd_code autoupdate_main(int argc, char **argv)
|
||||
rc1 = systemctl_cmd_path(globals.path_prefix, "is-enabled", "swupd-update.service", NULL);
|
||||
rc2 = systemctl_cmd_path(globals.path_prefix, "is-active", "swupd-update.timer", NULL);
|
||||
if (rc1 == SWUPD_OK && rc2 == SWUPD_OK) {
|
||||
print("Enabled\n");
|
||||
info("Enabled\n");
|
||||
return SWUPD_OK;
|
||||
} else if (rc1 >= STATUS_UNKNOWN || rc2 >= STATUS_UNKNOWN) {
|
||||
/* systemctl returns 1,2, or 3 when program dead or not running */
|
||||
@@ -173,7 +173,7 @@ enum swupd_code autoupdate_main(int argc, char **argv)
|
||||
error("Unable to determine autoupdate status with --path option\n");
|
||||
return SWUPD_SUBPROCESS_ERROR;
|
||||
} else {
|
||||
print("Disabled\n");
|
||||
info("Disabled\n");
|
||||
return SWUPD_NO;
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
# Author: Castulo Martinez
|
||||
# Email: castulo.martinez@intel.com
|
||||
|
||||
load "../testlib"
|
||||
|
||||
test_setup() {
|
||||
|
||||
create_test_environment "$TEST_NAME"
|
||||
sudo mkdir -p "$PATH_PREFIX"/etc/systemd/system
|
||||
|
||||
}
|
||||
|
||||
@test "API004: autoupdate" {
|
||||
|
||||
run sudo sh -c "$SWUPD autoupdate $SWUPD_OPTS --quiet"
|
||||
|
||||
assert_status_is "$SWUPD_NO"
|
||||
assert_output_is_empty
|
||||
|
||||
}
|
||||
|
||||
@test "API005: autoupdate --enable" {
|
||||
|
||||
# create mask files manually
|
||||
sudo ln -s /dev/null "$PATH_PREFIX"/etc/systemd/system/swupd-update.service
|
||||
sudo ln -s /dev/null "$PATH_PREFIX"/etc/systemd/system/swupd-update.timer
|
||||
|
||||
run sudo sh -c "$SWUPD autoupdate $SWUPD_OPTS --enable --quiet"
|
||||
|
||||
assert_status_is "$SWUPD_OK"
|
||||
assert_output_is_empty
|
||||
# check mask files don't exist
|
||||
assert_file_not_exists "$PATH_PREFIX"/etc/systemd/system/swupd-update.service
|
||||
assert_file_not_exists "$PATH_PREFIX"/etc/systemd/system/swupd-update.timer
|
||||
|
||||
}
|
||||
|
||||
@test "API006: autoupdate --disable" {
|
||||
|
||||
run sudo sh -c "$SWUPD autoupdate $SWUPD_OPTS --disable --quiet"
|
||||
|
||||
assert_status_is "$SWUPD_OK"
|
||||
assert_output_is_empty
|
||||
# check mask files don't exist
|
||||
assert_symlink_exists "$PATH_PREFIX"/etc/systemd/system/swupd-update.service
|
||||
assert_symlink_exists "$PATH_PREFIX"/etc/systemd/system/swupd-update.timer
|
||||
|
||||
}
|
||||
|
||||
@@ -4601,6 +4601,15 @@ assert_regex_is_not_output() { # assertion
|
||||
|
||||
}
|
||||
|
||||
assert_output_is_empty() { # assertion
|
||||
|
||||
if [ -n "$output" ]; then
|
||||
print_assert_failure "The output was expected to be empty and it is not"
|
||||
return 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
assert_equal() { # assertion
|
||||
|
||||
local val1=$1
|
||||
|
||||
Reference in New Issue
Block a user