Files
swupd-client/test/functional/api/api-3rd-party-repair.bats
Castulo Martinez 7dd6fc221a Testlib: renaming variables for consistency
Environment variables are used everywhere in testilb. This environment
variables are global variables that define the way testlib behaves.
However is was confusing to use the variables because they were
inconsistent between each other, for example some variables that define
paths would have absolute paths while other would have relative paths,
making it error prone while using them.

This commit makes the environment variables more consistent by following
a name convention for each type of variable, as an example, variables
that define absolute paths follow this convention ABS_<path_name>_DIR,
while variables that define relative paths are defined like this
<path_name>_DIR.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-16 11:42:13 -07:00

66 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bats
# Author: Castulo Martinez
# Email: castulo.martinez@intel.com
load "../testlib"
test_setup() {
create_test_environment "$TEST_NAME" 10 1
# add a 3rd-party repo with some "findings" for diagnose
create_third_party_repo -a "$TEST_NAME" 10 1 repo1
create_bundle -L -t -n test-bundle1 -f /foo/file_1,/bar/file_2 -u repo1 "$TEST_NAME"
create_version -p "$TEST_NAME" 20 10 1 repo1
update_bundle -p "$TEST_NAME" test-bundle1 --update /foo/file_1 repo1
update_bundle -p "$TEST_NAME" test-bundle1 --delete /bar/file_2 repo1
update_bundle "$TEST_NAME" test-bundle1 --add /baz/file_3 repo1
sudo touch "$TARGET_DIR"/"$TP_BUNDLES_DIR"/repo1/usr/untracked_file
set_current_version "$TEST_NAME" 20 repo1
# add another 3rd-party repo that has nothing to get fixed
create_third_party_repo -a "$TEST_NAME" 10 1 repo2
create_bundle -L -t -n test-bundle2 -f /baz/file_3 -u repo2 "$TEST_NAME"
}
@test "API060: 3rd-party repair" {
run sudo sh -c "$SWUPD 3rd-party repair $SWUPD_OPTS --picky --quiet"
assert_status_is "$SWUPD_OK"
expected_output=$(cat <<-EOM
[repo1]
$ABS_TARGET_DIR/opt/3rd-party/bundles/repo1/baz -> fixed
$ABS_TARGET_DIR/opt/3rd-party/bundles/repo1/baz/file_3 -> fixed
$ABS_TARGET_DIR/opt/3rd-party/bundles/repo1/foo/file_1 -> fixed
$ABS_TARGET_DIR/opt/3rd-party/bundles/repo1/usr/lib/os-release -> fixed
$ABS_TARGET_DIR/opt/3rd-party/bundles/repo1/bar/file_2 -> deleted
$ABS_TARGET_DIR/opt/3rd-party/bundles/repo1/usr/untracked_file -> deleted
[repo2]
EOM
)
assert_is_output "$expected_output"
}
@test "API061: 3rd-party repair --repo REPOSITORY" {
run sudo sh -c "$SWUPD 3rd-party repair $SWUPD_OPTS --picky --repo repo1 --quiet"
assert_status_is "$SWUPD_OK"
expected_output=$(cat <<-EOM
$ABS_TARGET_DIR/opt/3rd-party/bundles/repo1/baz -> fixed
$ABS_TARGET_DIR/opt/3rd-party/bundles/repo1/baz/file_3 -> fixed
$ABS_TARGET_DIR/opt/3rd-party/bundles/repo1/foo/file_1 -> fixed
$ABS_TARGET_DIR/opt/3rd-party/bundles/repo1/usr/lib/os-release -> fixed
$ABS_TARGET_DIR/opt/3rd-party/bundles/repo1/bar/file_2 -> deleted
$ABS_TARGET_DIR/opt/3rd-party/bundles/repo1/usr/untracked_file -> deleted
EOM
)
assert_is_output "$expected_output"
}
#WEIGHT=17