#!/usr/bin/env atf-sh . $(atf_get_srcdir)/test_env.sh init_tests \ setup_apkrepos_usage \ setup_apkrepos_exclusive_opts \ setup_apkrepos_https \ setup_apkrepos_random \ setup_apkrepos_first \ setup_apkrepos_fastest setup_apkrepos_usage_body() { test_usage setup-apkrepos } setup_apkrepos_exclusive_opts_body() { init_env atf_check -s exit:1 -e match:"usage" setup-apkrepos -r -f atf_check -s exit:1 -e match:"usage" setup-apkrepos -r -1 atf_check -s exit:1 -e match:"usage" setup-apkrepos -f -1 } setup_apkrepos_https_body() { init_env export MIRRORS="https://a.example.com http://b.example.com" atf_check -s exit:0 \ -o match:"Updating repository indexes..." \ -o match:"apk update" \ -e empty \ setup-apkrepos https://example.com grep -q 'https://example.com' etc/apk/repositories || atf_fail "example.com was not added to /etc/apk/repositories" } setup_apkrepos_random_body() { init_env export WGETCONTENT="$(seq 0 9 | awk '{print "https://a" $0 ".example.com"}')" atf_check -s exit:0 \ -o match:"Added mirror a[0-9].example.com" \ setup-apkrepos -r } setup_apkrepos_first_body() { init_env export WGETCONTENT="$(seq 0 9 | awk '{print "https://a" $0 ".example.com"}')" atf_check -s exit:0 \ -o match:"Added mirror a0.example.com" \ setup-apkrepos -1 } setup_apkrepos_fastest_body() { init_env export WGETCONTENT="$(seq 0 9 | awk '{print "https://a" $0 ".example.com"}')" atf_check -s exit:0 \ -e match:"^[0-9].*example.com" \ -o match:"Added mirror a[0-9].example.com" \ setup-apkrepos -f }