blob: 2b87d30f62f9111c532a3125e260016448a541d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
#!/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_network_failure \
setup_apkrepos_interactive \
setup_apkrepos_alpine_stable \
setup_apkrepos_alpine_edge
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
}
setup_apkrepos_network_failure_body() {
init_env
MIRRORS_URL=https://example.com/fail \
atf_check -s not-exit:0 \
-o match:"Finding" \
-e match:"Warning! No mirror found" \
setup-apkrepos -f
MIRRORS_URL=https://example.com/fail \
atf_check -s not-exit:0 \
-e match:"Warning" \
setup-apkrepos -r
MIRRORS_URL=https://example.com/fail \
atf_check -s not-exit:0 \
-e match:"Warning! No mirror found" \
setup-apkrepos -1
}
setup_apkrepos_interactive_body() {
init_env
export WGETCONTENT="$(seq 0 9 | awk '{print "https://a" $0 ".example.com"}')"
echo "1" > answers
atf_check -s exit:0 \
-o match:"Enter mirror number" \
setup-apkrepos < answers
}
setup_apkrepos_alpine_stable_body() {
init_env
export WGETCONTENT="$(seq 0 9 | awk '{print "https://a" $0 ".example.com"}')"
mkdir -p etc
echo "3.17.0" > etc/alpine-release
atf_check -s exit:0 \
-o match:"Added mirror a0.example.com" \
setup-apkrepos -1
atf_check -o match:"v3\.17" cat etc/apk/repositories
}
setup_apkrepos_alpine_edge_body() {
init_env
export WGETCONTENT="$(seq 0 9 | awk '{print "https://a" $0 ".example.com"}')"
mkdir -p etc etc/apk
# edge may have a .0 in etc/alpine-release
echo "3.17.0" > etc/alpine-release
echo "https://dl-cdn.alpinelinux.org/alpine/edge/main" > etc/apk/repositories
atf_check -s exit:0 \
-o match:"Added mirror a0.example.com" \
setup-apkrepos -1
atf_check \
-o match:"https://a0.example.com/edge/main" \
-o not-match:"v3\.17" \
cat etc/apk/repositories
}
|