mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-08-28 09:55:59 +00:00
7dd6fc221a
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>
137 lines
3.9 KiB
Bash
Executable File
137 lines
3.9 KiB
Bash
Executable File
#!/usr/bin/env bats
|
|
|
|
|
|
# Author: Castulo Martinez
|
|
# Email: castulo.martinez@intel.com
|
|
|
|
load "../testlib"
|
|
|
|
global_setup() {
|
|
|
|
create_test_environment "$TEST_NAME"
|
|
create_bundle -L -n test-bundle1 -f /file_1,/foo/file_2 "$TEST_NAME"
|
|
create_bundle -e -n test-bundle2 -f /file_3,/bar/file_4 "$TEST_NAME"
|
|
create_version "$TEST_NAME" 20 10
|
|
update_bundle "$TEST_NAME" test-bundle1 --update /file_1
|
|
create_version "$TEST_NAME" 30 20
|
|
update_bundle "$TEST_NAME" test-bundle1 --add /foo/file_5
|
|
# when swupd initializes, if the tracking directory is empty, it will
|
|
# mark all installed bundles as tracked, to avoid this, let's add a dummy
|
|
# value to the tracking directory
|
|
sudo touch "$ABS_TRACKING_DIR"/dummy
|
|
|
|
}
|
|
|
|
@test "BIN001: Show info about a bundle installed in the system" {
|
|
|
|
# users can use the bundle-info command to see detailed info about a bundle
|
|
# if the bundle is installed it should show when it was last updated and
|
|
# how much disk space is taking
|
|
|
|
run sudo sh -c "$SWUPD bundle-info $SWUPD_OPTS test-bundle1"
|
|
|
|
assert_status_is "$SWUPD_OK"
|
|
expected_output=$(cat <<-EOM
|
|
_______________________________
|
|
Info for bundle: test-bundle1
|
|
_______________________________
|
|
Status: Installed
|
|
There is an update for bundle test-bundle1:
|
|
- Installed bundle last updated in version: 10
|
|
- Latest available version: 30
|
|
Bundle size:
|
|
- Size of bundle: .* KB
|
|
- Size bundle takes on disk \\(includes dependencies\\): .* KB
|
|
EOM
|
|
)
|
|
assert_regex_in_output "$expected_output"
|
|
|
|
}
|
|
|
|
@test "BIN002: Show info about a bundle not installed in the system" {
|
|
|
|
# users can use the bundle-info command to see detailed info about a bundle
|
|
# if the bundle is not installed it should show the latest available version
|
|
# and how much disk space it would take if installed
|
|
# also bundles that are experimental are marked as such in the status
|
|
|
|
run sudo sh -c "$SWUPD bundle-info $SWUPD_OPTS test-bundle2"
|
|
|
|
assert_status_is "$SWUPD_OK"
|
|
expected_output=$(cat <<-EOM
|
|
_______________________________
|
|
Info for bundle: test-bundle2
|
|
_______________________________
|
|
Status: Not installed \\(experimental\\)
|
|
Latest available version: 10
|
|
Bundle size:
|
|
- Size of bundle: .* KB
|
|
- Maximum amount of disk size the bundle will take if installed \\(includes dependencies\\): .* KB
|
|
EOM
|
|
)
|
|
assert_regex_is_output "$expected_output"
|
|
|
|
}
|
|
|
|
@test "BIN003: Show info about a bundle for a particular system version" {
|
|
|
|
# a specific version can be specified to display info
|
|
|
|
run sudo sh -c "$SWUPD bundle-info $SWUPD_OPTS test-bundle1 --version 20"
|
|
|
|
assert_status_is "$SWUPD_OK"
|
|
expected_output=$(cat <<-EOM
|
|
_______________________________
|
|
Info for bundle: test-bundle1
|
|
_______________________________
|
|
Status: Installed
|
|
There is an update for bundle test-bundle1:
|
|
- Installed bundle last updated in version: 20
|
|
- Latest available version: 30
|
|
Bundle size:
|
|
- Size of bundle: .* KB
|
|
- Size bundle takes on disk \\(includes dependencies\\): .* KB
|
|
EOM
|
|
)
|
|
assert_regex_in_output "$expected_output"
|
|
|
|
}
|
|
|
|
@test "BIN004: Show info about a bundle for a particular system version" {
|
|
|
|
# version can take latest or current
|
|
|
|
run sudo sh -c "$SWUPD bundle-info $SWUPD_OPTS test-bundle1 --version latest"
|
|
|
|
assert_status_is "$SWUPD_OK"
|
|
expected_output=$(cat <<-EOM
|
|
_______________________________
|
|
Info for bundle: test-bundle1
|
|
_______________________________
|
|
Status: Installed
|
|
Bundle test-bundle1 is up to date:
|
|
- Installed bundle last updated in version: 30
|
|
- Latest available version: 30
|
|
Bundle size:
|
|
- Size of bundle: .* KB
|
|
- Size bundle takes on disk \\(includes dependencies\\): .* KB
|
|
EOM
|
|
)
|
|
assert_regex_in_output "$expected_output"
|
|
|
|
}
|
|
|
|
@test "BIN005: Try to show info about an invalid bundle" {
|
|
|
|
run sudo sh -c "$SWUPD bundle-info $SWUPD_OPTS bad-bundle"
|
|
|
|
assert_status_is "$SWUPD_INVALID_BUNDLE"
|
|
expected_output=$(cat <<-EOM
|
|
Error: Bundle "bad-bundle" is invalid
|
|
EOM
|
|
)
|
|
assert_is_output "$expected_output"
|
|
|
|
}
|
|
#WEIGHT=6
|