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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
mod common;
use aur_build::db::{self, builds, model::*};
use aur_build::pipeline;
use aur_build::review::candidates;
use common::*;
#[test]
fn attention_lists_a_downgrade_when_aur_moves_below_what_we_serve() {
let web = Web::new("plain-make");
web.publish("plain-make");
assert!(!web.get("/attention").body.contains("Downgrades"), "nothing is stale yet");
web.fx.bump(&[("pkgver", "0.9")]);
aur_build::watch::detect::check_pkgbase(&web.env.cfg, &web.env.db, "plain-make").unwrap();
let page = web.get("/attention");
assert_eq!(page.status, 200);
assert!(page.body.contains("Downgrade"), "no downgrade section: {}", &page.body[..400.min(page.body.len())]);
assert!(page.body.contains("0.9"), "the offered version is not shown");
assert!(page.body.contains("1.0"), "the served version is not shown");
}
#[test]
fn attention_lists_outdated_dependencies_from_the_recorded_world() {
let (env, plain, client) = env_with_two_fixtures("plain-make", "dep-client");
let web = Web::attach(env, client);
web.publish("plain-make");
web.publish("dep-client");
assert!(
!web.get("/attention").body.contains("Outdated:"),
"dep-client is fresh right after both were published"
);
plain.bump(&[("pkgver", "2.0")]);
web.publish("plain-make");
let page = web.get("/attention");
assert!(page.body.contains("Outdated:"), "no outdated section: {}", &page.body[..600.min(page.body.len())]);
assert!(page.body.contains("dep-client"), "the stale package is not named");
assert!(page.body.contains("plain-make"), "the dependency is not named");
assert!(page.body.contains("1.0") && page.body.contains("2.0"), "the built-against/now pair is missing");
}
#[test]
fn the_package_page_answers_dependencies_and_staleness() {
let (env, plain, client) = env_with_two_fixtures("plain-make", "dep-client");
let web = Web::attach(env, client);
web.publish("plain-make");
web.publish("dep-client");
plain.bump(&[("pkgver", "2.0")]);
web.publish("plain-make");
let page = web.get("/packages/dep-client");
assert_eq!(page.status, 200);
assert!(page.body.contains("Depends on"), "no depends block");
assert!(page.body.contains("plain-make"), "the dependency is not listed");
assert!(page.body.contains("Stale"), "staleness is not shown on the package page");
let other = web.get("/packages/plain-make");
assert!(other.body.contains("Needed by"), "no needed-by block");
assert!(other.body.contains("dep-client"), "the dependent is not listed");
assert!(other.body.contains("aur.archlinux.org/cgit/aur.git/tree/?h=plain-make&id="), "no per-release cgit link");
assert!(other.body.contains("serving 2.0"), "the summary does not say what is served");
}
#[test]
fn a_manual_rebuild_reuses_the_approved_identity_without_a_new_approval() {
let web = Web::new("plain-make");
web.publish("plain-make");
let approvals_before = web.env.query_i64("SELECT count(*) FROM approval", &[]).unwrap();
assert_eq!(approvals_before, 1);
let res = web.post("/packages/plain-make/rebuild", &[("csrf", &web.csrf)]);
assert_eq!(res.status, 200, "rebuild should be accepted: {}", &res.body[..200.min(res.body.len())]);
assert!(res.body.contains("no new approval"), "the confirmation does not say why no approval is needed");
assert_eq!(
web.env.query_i64("SELECT count(*) FROM approval", &[]).unwrap(),
approvals_before,
"a manual rebuild must not mint an approval"
);
let queued = web
.env
.query_i64("SELECT count(*) FROM build WHERE kind='manual_rebuild'", &[])
.unwrap();
assert_eq!(queued, 1, "the rebuild was not queued");
let id: String = web
.env
.db
.read(|c| {
use rusqlite::OptionalExtension;
c.query_row(
"SELECT id FROM build WHERE kind='manual_rebuild'",
[],
|r| r.get::<_, String>(0),
)
.optional()
.map_err(Into::into)
})
.unwrap()
.unwrap();
pipeline::run(&web.env.cfg, &web.env.db, &id).unwrap();
let b = builds::get(&web.env.db, &id).unwrap().unwrap();
assert_eq!(b.state, BuildState::Succeeded, "rebuild failed: {:?}", b.error);
assert_eq!(
web.env.query_i64("SELECT count(*) FROM approval", &[]).unwrap(),
approvals_before,
"running a rebuild must not mint an approval either"
);
assert_eq!(db::index_version(&web.env.db, "plain-make").unwrap().as_deref(), Some("1.0-1"));
}
#[test]
fn the_builds_page_names_the_version_and_the_audit_page_records_the_decision() {
let web = Web::new("plain-make");
web.publish("plain-make");
let page = web.get("/builds");
assert_eq!(page.status, 200);
assert!(page.body.contains("plain-make"), "the build row has no pkgbase");
assert!(page.body.contains("1.0-1"), "the build row has no version: {}", &page.body[..600.min(page.body.len())]);
assert!(page.body.contains("succeeded") || page.body.contains("Succeeded"), "the finished build is not shown");
let audit = web.get("/audit");
assert!(audit.body.contains("approve"), "the approval is not in the audit log");
assert!(audit.body.contains("test") || audit.body.contains("cli"), "no actor recorded");
}
#[test]
fn the_subscriptions_page_shows_state_and_last_check() {
let web = Web::new("plain-make");
web.publish("plain-make");
let page = web.get("/subscriptions");
assert_eq!(page.status, 200);
assert!(page.body.contains("plain-make"), "the subscription is not listed");
assert!(page.body.contains("active"), "no state shown");
assert!(page.body.contains("action=\"/subscriptions/pause\""), "no pause form");
assert!(page.body.contains("action=\"/subscriptions/remove\""), "no remove form");
}
#[test]
fn pausing_a_subscription_stops_detection_and_resuming_starts_it_again() {
let web = Web::new("plain-make");
web.post("/subscriptions/pause", &[("csrf", &web.csrf), ("pkgbase", "plain-make")]);
assert_eq!(
web.env.query_i64("SELECT count(*) FROM subscription WHERE state='paused'", &[]),
Some(1),
"pause did not take"
);
web.fx.bump(&[("pkgver", "3.0")]);
let report = aur_build::watch::detect::check_pkgbase(&web.env.cfg, &web.env.db, "plain-make").unwrap();
assert!(matches!(report.outcome, aur_build::watch::detect::Outcome::Paused), "a paused subscription was still inspected");
assert_eq!(
candidates::pending_candidates(&web.env.db).unwrap().len(),
0,
"a paused subscription produced a candidate"
);
web.post("/subscriptions/pause", &[("csrf", &web.csrf), ("pkgbase", "plain-make")]);
aur_build::watch::detect::check_pkgbase(&web.env.cfg, &web.env.db, "plain-make").unwrap();
assert_eq!(candidates::pending_candidates(&web.env.db).unwrap().len(), 1, "resuming did not restore detection");
}
|