#!/bin/bash

. ./libtest.sh

test_download_failed() {
    info "测试 下载过程时 无法连接到服务端仓库的报错"

    fn_simulate_ostree_system
    new_brach="testos/buildmaster/newbranch1"
    os_repository_new_commit 1 1 $new_brach
    newrev=$(${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo rev-parse $new_brach)

    ${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit $metadata_string --add-metadata-string new_version=1.0.11 -b $BUILD_MASTER_BRACH -s "Build" --tree=dir=$OS_DATA

    push_content="testos:${new_brach}@$newrev"

    echo "$push_content" > $PUSH_FILE

    echo "检查更新"
    gdbus call --system --dest $bus_name --object-path $object_path --method $interface_name.$update_method > /dev/null
    moniter_signal_success $update_finished_signal

    # 杀掉下载服务器
    pkill -f "python3 -m http.server 8889"

    echo "部署下载"
    gdbus call --system --dest $bus_name --object-path $object_path --method $interface_name.$download_method > /dev/null
    moniter_string "$download_finished_signal success = False , upgrade_group = \['kylin-update-desktop-system'\]"


}


test_download_failed